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 |
|
larryg003
Starting Member
18 Posts |
Posted - 2010-06-12 : 13:13:12
|
| Hey guys, this is my 5th post on this forum and I really pleased with all of the great responses/help i've recieved. Thanks a lot!!!!Now, a simple question regarding order:Suppose I have Columns: A and BA has tags B has languageThe statementselect * from tablewhere [Column_A] like '%ABC%'or [Column_A] like '%DEF%'Will display all of the fields where column A contains the string ABC or Column A contains the string DEF.Now suppose I add the line and [Column_B] like '%ENGLISH%'What tool do I use to separate the scenarios1.) Where Column A contains 'ABC' or Column A contains 'DEF'and Column_B contains 'ENGLISH' for bothor 2.) Where Column A contains 'ABC', OR (Column A contains 'DEF' and Column B contains 'ENGLISH'). (Column A must contain ABC and doesn't have to have Column B contain 'ENGLISH'; or Column A must have 'DEF' and Column B contains 'ENGLISH')Do I use parantheses to seperate these distinct statements or must I run a subquery?Is their a way to bypass the subquery distinguish between these two using another format?Cheers,-Larry*CHANGES MADE |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-06-12 : 14:03:11
|
| You can just use parentheses1)Where column_b like '%English%' and(column_a like '%ABC%' OR column_a like '%DEF%')2)Where column_a like '%ABC%' or (column_a like '%DEF%' and column_b like '%english%')JimEveryday I learn something that somebody else already knew |
 |
|
|
|
|
|