sql - Is it possible to use LIKE and IN for a WHERE statment? -


i have list of place names , match them records in sql database problem properties have reference numbers after there name. eg. 'ballymena p-4sdf5g' possible use in , match records

where dbo.[places].[name] in like('ballymena%','banger%') 

it's common misconception construct

b in (x, y, z) 

that (x, y, z) represents set. not.

rather, merely syntactic sugar for

(b = x or b = y or b = z) 

sql has 1 data structure: table. if want query search text values set put them table. can join search text table places table using like in join condition e.g.

with places (name)           (       select name         (               values ('ballymeade country club'),                       ('ballymena candles'),                       ('bangers & mash cafe'),                       ('bangebis')              ) places (name)      ),       searchtext (search_text)           (       select search_text         (               values ('ballymena'),                       ('banger')              ) searchtext (search_text)      ) select *    places p1        left outer join searchtext s1           on p1.name s1.search_text + '%'; 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -