我的db表如下
TestTable的
|-----|-------------------|
Id comment
2 | 20 degree celsius
3 | 30 degree Farenheit
4 | 40 degree Farenheit
5 | sometime
6 | plain text
7 | plain text
8 | plain text
Run Code Online (Sandbox Code Playgroud)
我想查询db以获取string包含celsius或farenheit的所有id
查询:
SELECT Id FROM testTable where id in (2,3,4)
AND comment like '%celsius%' or comment like '%Farenheit%'
Run Code Online (Sandbox Code Playgroud)
但是这个查询检查所有的ID,而不是我在条件中提供的id?如何只查询条件中的id?
只需使用这样的括号:
SELECT Id FROM testTable where id in (2,3,4)
AND
(comment like '%celsius%' or comment like '%Farenheit%')
Run Code Online (Sandbox Code Playgroud)