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.
Author |
Topic |
strikeuk
Starting Member
2 Posts |
Posted - 2008-03-06 : 09:18:57
|
Hi guys, need some help with the following, assuming i have the following two tablesTable1CustomerNo CustomerName1 ABC2 XYZ3 QWETable2DocNo CustomerNo Paid8000001 2 Y8000002 1 Y8000003 1 Y8000004 3 N8000005 4 Y and the following sql scriptselect CustomerName,DocNofrom table2 left join table1on table2.CustomerNo = table1.CustomerNoand paid = 'Y'why am i still getting five rows of records instead of just four? As i understand it will pull out all the rows from table2 irregardless of whether there are any matching records in table1, but i've already included the condition to only pick "Y" but it's still pulling out all the records.i need to pull out the info based on the following condition1)customer already paid2)doesn't care whether the customer number is in or notmeaning to say i need to pull out all the transactions even if the customer number doesn't exist in the customer table but it has to have the condition of already being paid. Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-06 : 09:47:53
|
Try:-select CustomerName,DocNofrom table2 left join table1on table2.CustomerNo = table1.CustomerNoWhere paid = 'Y' |
 |
|
|
|
|