¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita0
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 Respuestas
+ 4
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%';
+ 3
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%’) ;
+ 1
Thanks a lot that solved my query.