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 |
|
neutcomp
Posting Yak Master
111 Posts |
Posted - 2003-07-04 : 06:31:26
|
Hello,I have:tbl_linkidid_mailid_personid id_mail id_person18 14 20519 15 20520 16 2621 17 20522 18 205tbl_emailidactionCodeid actionCode14 Christmas card15 Easter card16 Christmas card17 Discount action18 Summer sale This is to make a mailing to a selected group of people.Now I want to make a selection. I want everyone how has not received a "summer sale". So the result is id 26. Now I want everyone how has not received "Christmas card". So the result is NOTTHING.ThanxxBjorn |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2003-07-04 : 06:37:15
|
| SELECT id_personFROMtbl_link aLEFT OUTER JOIN ( SELECT id from tbl_email WHERE actionCode = 'Christmas card' ) bON b.[id] = a.id_mailWHERE b.id is nullHmm, on second thoughts I don't think that will work, but it's a starting point.-------Moo. |
 |
|
|
neutcomp
Posting Yak Master
111 Posts |
Posted - 2003-07-04 : 06:51:40
|
quote: SELECT id_personFROMtbl_link aLEFT OUTER JOIN ( SELECT id from tbl_email WHERE actionCode = 'Christmas card' ) bON b.[id] = a.id_mailWHERE b.id is nullHmm, on second thoughts I don't think that will work, but it's a starting point.-------Moo.
Nop The statement is not going to work.Anyone else? |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2003-07-04 : 08:16:30
|
| SELECT id_personFROM tbl_link left outer join (SELECT id_personFROMtbl_link aINNER JOIN ( SELECT id from tbl_email WHERE actionCode = 'Christmas card' ) bON b.[id] = a.id_mail) con c.id_person = tbl_link.id_personand c.id_person is nullorSELECT id_personFROM tbl_link where id_person not in(SELECT id_personFROMtbl_link aINNER JOIN ( SELECT id from tbl_email WHERE actionCode = 'Christmas card' ) bON b.[id] = a.id_mail) -------Moo. |
 |
|
|
|
|
|