如何组合来自三个类似语句的 sql 查询?我正在尝试这样:
SELECT * FROM myTable
WHERE
(NAME LIKE '%someChars%' AND
(CITY LIKE '%someChars%' AND
TYPE LIKE'% someChars%')
);
它不起作用,你能帮我吗?
查询是正确的,除了它Type
是一个 sql 关键字,所以试着把它放在括号之间:
SELECT * FROM [myTable]
WHERE ([NAME] LIKE '%someChars%' AND
([CITY] LIKE '%someChars%' AND
[TYPE] LIKE '%someChars%'));
PS:括号不是必须的
SELECT *
FROM myTable
WHERE
NAME LIKE '%someChars%' AND
CITY LIKE '%someChars%' AND
TYPE LIKE '%someChars%';