Search by like on sql server 2005
-
23 мая 2012 г. 11:46
Hi, I am doing a search by like on sql server 2005 with
select * from tableA
where ColumnB like 'Key1'
or ColumnB like 'Key2'How can I keep track of the results so that I can know which key is hit on the search?
Все ответы
-
24 мая 2012 г. 4:34Модератор
Hi CMF0923,
If you are trying to return rows with the value of 'ColumnB' in 'Key1' and 'Key2', you can use '=' instead of 'like'. In this case, the result of two columns will indicate the match conditions:
select * from tableAwhere ColumnB ='Key1' or ColumnB ='Key2'
Stephanie Lv
TechNet Community Support
-
24 мая 2012 г. 8:24
HI, I need to search the Key from the content, which may not be an exact match. Below is my edited query.
select * from tableA where ColumnB like '%Key1%' or ColumnB like '%Key2%'
-
4 июня 2012 г. 8:23Модератор

