Solved

select query troubles

Posted on 2008-10-26
3
276 Views
Last Modified: 2013-12-13
I have a select query which works fine.

but I want toe exclude a result where catid = 126 How do I do this.

SELECT * FROM categories WHERE Parentid = 0 AND ORDER by catname
0
Comment
Question by:Cheryl Lander
  • 2
3 Comments
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 22809223
You just add that to the WHERE clause like this:

SELECT *
FROM Categories
WHERE ParentId = 0 AND CatId <> 126
ORDER BY CatName
0
 
LVL 27

Expert Comment

by:yodercm
ID: 22809240
mwvisa1 is correct, except you need to watch capitalization on the table name:

SELECT * FROM categories WHERE Parentid = 0 AND catid!=126 ORDER by catname
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 22809241
Depending on what database platform, the not equal may be != so the query would be:

CatId != 126.

If I am misunderstanding the exclude portion of the question you would just change this to be:

CatId = 126
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article describes some very basic things about SQL Server filegroups.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now