Q
Problem solve Get help with specific problems with your technologies, process and projects.

Views vs. the WHERE clause

Can I select a particular department's information from an employee table without using the WHERE clause? My employee table contains the following columns: EMPNO, ENAME, DEPTNO, SAL, COMM, HIREDATE

I'm not sure I understand your question. If I do, this sounds like a good place to use a view. Your view could look like this:

CREATE VIEW Department7 AS 
SELECT EMPNO, ENAME, DEPTNO, SAL, COMM, HIREDATE
  FROM Employee
  WHERE DEPTNO = 7

Then, you could select from it without using a where clause:

SELECT * 
  FROM Department7

For More Information

  • What do you think about this answer? E-mail the Edtior at tdichiara@techtarget.com with your feedback.
  • The Best SQL Web Links: tips, tutorials, scripts, and more.
  • Have a SQL tip to offer your fellow DBA's and developers? The best tips submitted will receive a cool prize--submit your tip today!
  • Ask your technical SQL questions--or help out your peers by answering them--in our live discussion forums.
  • Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.

Dig Deeper on Oracle and SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close