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)
 Need Help with a query

Author  Topic 

seanb
Starting Member

1 Post

Posted - 2008-05-21 : 19:07:39
I'm having issues pulling the wrong data so I thought I would ask you guys for some help. This sql is supposed to be displaying the records where either the account hasn't set a credit card or a address. I know I must have messed something up because pulling out the where returns the wrong data (there are no accounts with no address or card number being shown). Heres the query below:

SELECT * FROM MEMBER m
RIGHT OUTER JOIN MEMBER_LOCATION m1 on m.MEMBERID = m1.MEMBERID
RIGHT OUTER JOIN LOCATION l1 on m1.LOCATIONID = l1.LOCATIONID
INNER JOIN ACCOUNT a1 on m.CUSTOMERID = a1.CUSTOMERID
RIGHT OUTER JOIN CREDIT_CARD cc on a1.ACCOUNTID = cc.ACCOUNTID
WHERE (ml.STREET = '' OR cc.CARD_NUMBER = '')

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-05-21 : 19:18:15
Could you show us a data example of what you mean? What is your query currently showing? What is it supposed to show? What does the data in the tables look like?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page
   

- Advertisement -