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 |
|
wylderubicon
Starting Member
10 Posts |
Posted - 2008-02-29 : 10:30:19
|
| One more question.I need to use select using some type of a prior omit.for example, I have 2 selects:select * from table abc where zip in ('07661') and name like 'A%'goselect * from table abc where zip in ('07661') and company like 'ABC&'there could be common records in both select statements, but I want to exclude the same records from the first select when I run my second one.I could sayselect * from table abc where zip in ('07661') and company like 'ABC&' and name not like 'A%' in my second select, but I rather not do that, since my queries has many select criterias and its not just 2 selects.So is there another option? a subsitution for "go"?thanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-29 : 10:33:23
|
| select * from table abc where zip in ('07661') and name like 'A%'exceptselect * from table abc where zip in ('07661') and company like 'ABC&'MadhivananFailing to plan is Planning to fail |
 |
|
|
wylderubicon
Starting Member
10 Posts |
Posted - 2008-02-29 : 10:47:40
|
| this will not return the results of the first select which I need as well. |
 |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2008-02-29 : 11:14:37
|
| select * from table abc where zip in ('07661') and (company like 'ABC&' OR name like 'A%')-- or -- select * from table abc where zip in ('07661') and name like 'A%'unionselect * from table abc where zip in ('07661') and company like 'ABC&'=================================================Creating tomorrow's legacy systems today. One crisis at a time. |
 |
|
|
|
|
|