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 |
|
dogli
Starting Member
32 Posts |
Posted - 2002-10-07 : 11:04:21
|
| Hi SQL Guru here,I have a questions about the following two queries:1) Select * from tableAwhere ((columnA ='aa' And ColumnB='BB')or (columnA ='aa' And ColumnB='cc')or (columnA ='dd' And ColumnB='BB'))2) Select * from tableAwhere (columnA in ('aa','dd') and columnB in ('BB','CC'))Can I get the same results with them?Thanks |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-10-07 : 11:15:09
|
| nope.The second will include columnA ='dd' And ColumnB='CC'whereas the first won't.Select * from tableA where ((columnA = 'aa' and columnB in ('BB','CC')or (columnA = 'dd' and ColumnB='BB')) ==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
monkeybite
Posting Yak Master
152 Posts |
Posted - 2002-10-07 : 11:15:31
|
| My initial thought is no. With the second query you will return rows where columnA = 'dd' and columnB = 'cc', which is not possible in the first query.-- monkey |
 |
|
|
dogli
Starting Member
32 Posts |
Posted - 2002-10-07 : 11:35:11
|
| Thanks! Both of you are right,I have changed the query! |
 |
|
|
ksw
Starting Member
24 Posts |
Posted - 2002-10-09 : 15:44:01
|
| For readability, I like writing these types of where clauses as follows.SELECT *FROM tableAWHERE ColumnA + ColumnB IN ('aabb', 'aacc', 'ddbb')--KSW |
 |
|
|
Sitka
Aged Yak Warrior
571 Posts |
Posted - 2002-10-12 : 19:50:21
|
| thanks kswVoted best SQL forum nickname...."Tutorial-D" |
 |
|
|
|
|
|