Solved

select query troubles

Posted on 2008-10-26
3
289 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 60

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: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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

617 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