Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HAVING in Select statment

Status
Not open for further replies.

beyondflash

Programmer
Sep 4, 2005
8
US
I have multiple items that I don't want selected in my select statement...I can get ONE to work here is a sample:

$sql = "SELECT * FROM login
WHERE (Email = '$email') HAVING Crsnum != 1 ORDER BY ID DESC";

This will not select any Crsnum that =1...
The problem I am having is I have multiple crsnum's that cannot be selected example:

1,4,9,17,19

How do I create the SELECT statement to omit those index numbers from being selected??

Thanks.
 
may be you need to use IN key word...

WHERE Crsnum IN (1,4,9,17,19)

-DNG
 
when I add a second WHERE I get an sql error msg

$sql = "SELECT * FROM login
WHERE (Email = '$email')
WHERE crsnum NOT IN (1,4,9,17,19)
ORDER BY ID DESC";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top