Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

select query troubles

Posted on 2008-10-26
3
Medium Priority
?
295 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 60

Accepted Solution

by:
Kevin Cross earned 2000 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:Cornelia Yoder
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 60

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

972 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