Sql LIKE and IN together | Sololearn: Learn to code for FREE!


Sql LIKE and IN together

Hi everyone. Pretty new to SQL so any help will be much appreciated. Is there a way to combine link and in into the following: SELECT year, centre FROM Data WHERE Centre LIKE IN (‘%20-20%’, ‘%20-30%’); Does not work. Just need to get rows of data with centres with those texts in the string. Thanks

3/26/2019 1:29:27 PM

Adnan Mansoor Yousaf

3 Answers

New Answer


You can think of 'IN' as a simplified chain of 'OR' expressions. So you can write the query like this: SELECT year, centre FROM data WHERE centre LIKE '%20-20%' OR centre LIKE '%20-30%';


Nope. There can be only a single WHERE clause. But you can use parentheses to group any number of conditions, like this: WHERE year =18 AND (centre LIKE ‘%20-20%’ OR centre LIKE ‘%20-30%’) ;


Thanks a lot that solved my query.