Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Is there something wrong with my code

Author  Topic 

disciple
Starting Member

27 Posts

Posted - 2006-03-30 : 00:02:12

SELECT * FROM BOOK_CUSTOMER WHERE STATE='FL' OR STATE='NJ' AND REFERRED=NULL;

Im sorry for posting this, but the results just arent working out. Im trying to display user information if the customer lives in florida or new jersey and they cant have a referring user. I tried the above combination and managed to only list the people from fl and got one user who was referred. I also tried:

SELECT * FROM BOOK_CUSTOMER WHERE REFERRED=NULL AND STATE='FL' OR STATE='NJ';

And I only get people from nj and also get one referred user. Can anyone point out what im doing wrong?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-30 : 00:06:13
use
REFERRED IS NULL





KH

Choice is an illusion, created between those with power, and those without.
Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant

Go to Top of Page

disciple
Starting Member

27 Posts

Posted - 2006-03-30 : 00:08:05
That managed to get both fl and nj users to show.. but for some wierd reason one referred user is still showing
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-30 : 00:10:18
Post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

disciple
Starting Member

27 Posts

Posted - 2006-03-30 : 00:10:41
I put (STATE='FL' OR STATE='NJ') and that seemed to clear up my problem. Thanks for you help!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-30 : 00:16:05
or you can also use STATE IN ('FL', 'NJ')



KH

Choice is an illusion, created between those with power, and those without.
Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant

Go to Top of Page
   

- Advertisement -