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 |
|
bpsintl
Posting Yak Master
132 Posts |
Posted - 2009-04-02 : 03:50:49
|
| I have 2 tables, invoices and income.Invoices TableIDtotalIncome Tableincome_idinvoiceidamountThere are more fields in each table but they are the ones relating to my query.Basically, my system creates a row in the income table each time an invoice is created, so that we can reconcile it with the bank when the bank statement comes.My problem is that I found some instances when these income rows were not created.I would like to query those tables and bring back all invoice records that do not have a corresponding income row on invoices.id = income.invoiceidI've tried left and right joins but dont think I'm getting it right. |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2009-04-02 : 07:30:42
|
| select * from invoices iv left join income icon iv.id = ic.invoiceidwhere ic.income_id is nullEm |
 |
|
|
bpsintl
Posting Yak Master
132 Posts |
Posted - 2009-04-02 : 07:38:49
|
| Cheers Em, thats the ticket!! |
 |
|
|
|
|
|