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!

No matter what i try it doesn't return the records! 1

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
I am having trouble with a SQL statement

This code works right it returns all records in userwindow as null except one which has uw.waction=2 this is right... but as you see on the second code i have tried everything to not show records that have uw.waction=2
Code:
Select th.tid, th.tname, th.tmain, th.tcolor,coalesce(c.postnumber,0) as posts, uw.wuid, uw.wwid, uw.waction FROM thread AS th left JOIN ( SELECT ptid, sum(ptype=0) as postnumber FROM forumpost GROUP by ptid) as c on c.ptid = th.tid LEFT JOIN userwindow uw ON uw.wwid=th.tid AND uw.wuid=2 WHERE th.tmain=1


Code:
Select th.tid, th.tname, th.tmain, th.tcolor,coalesce(c.postnumber,0) as posts, uw.wuid, uw.wwid, uw.waction FROM thread AS th left JOIN ( SELECT ptid, sum(ptype=0) as postnumber FROM forumpost GROUP by ptid) as c on c.ptid = th.tid LEFT JOIN userwindow uw ON uw.wwid=th.tid AND uw.wuid=2 WHERE th.tmain=1 AND uw.waction<>2

I have tried to do coalesce on uw.waction and then show all 0 values in waction, that didnt work... i have tried != and <> and its not returning anything back...


Any ideas?

Regards,
Jason


Jason

[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]

 
Try this....

[tt][blue]WHERE th.tmain=1 AND uw.waction [!]Is Null[/!][/blue][/tt]

Null will not compare to any value. To check if a column contains a null, you need to use the IS operator.

Make sense?

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Thanks a lot!

Jason

[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top