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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 best method?

Author  Topic 

adam84
Starting Member

1 Post

Posted - 2007-07-30 : 03:13:00
i have two sql tables


businesses

[shopid], [shopname], [phone], [address], [logo]

deals

[dealid], [shopid], [dealtext], [startdate],[ enddate]


i display the shops from business first and if a shop is clicked then the deals the shop has are then displayed.

The problem is that if there are no deals the shop is still displayed, what i want to do is if there are no valid deals for the shop then it is not retrieved.

SELECT businesses.shopname, businesses.logo, businesses.shopid FROM (businesses INNER JOIN deals ON businesses.shopid = deals.shopid) WHERE (businesses.activecampaign = '1') AND (deals.startdate <= NOW()) AND (deals.enddate >= NOW())

How can i edit my sql command to only query shops from businesses if they have a valid deal (valid deal is that its date is valid)

Kristen
Test

22859 Posts

Posted - 2007-07-30 : 03:26:18
"valid deal is that its date is valid"

Add a test for this in the WHERE clause then.

Kristen
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-30 : 03:45:13
This could be an presentation issue.
If no records are returned, you have to check for this condition, and still clear deals list.

Or better. Always clear deals list BEFORE running your query to get deals.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -