如何结合三个类似语句的sql查询?我试着这样:
SELECT * FROM myTable
WHERE
(NAME LIKE '%someChars%' AND
(CITY LIKE '%someChars%' AND
TYPE LIKE'% someChars%')
);
它不起作用,你能帮帮我吗?
答案 0 :(得分:1)
除了Type
是一个sql关键字之外,查询是正确的,所以请尝试将它放在括号之间:
SELECT * FROM [myTable]
WHERE ([NAME] LIKE '%someChars%' AND
([CITY] LIKE '%someChars%' AND
[TYPE] LIKE '%someChars%'));
PS:不需要括号
答案 1 :(得分:0)
SELECT *
FROM myTable
WHERE
NAME LIKE '%someChars%' AND
CITY LIKE '%someChars%' AND
TYPE LIKE '%someChars%';