Solved

select query troubles

Posted on 2008-10-26
3
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

749 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