0

如何组合来自三个类似语句的 sql 查询?我正在尝试这样:

SELECT * FROM myTable 
WHERE 
  (NAME LIKE '%someChars%' AND 
    (CITY LIKE '%someChars%' AND 
     TYPE LIKE'% someChars%')
  );

它不起作用,你能帮我吗?

4

2 回答 2

1

查询是正确的,除了它Type是一个 sql 关键字,所以试着把它放在括号之间:

SELECT * FROM [myTable] 
 WHERE ([NAME] LIKE '%someChars%' AND
        ([CITY] LIKE '%someChars%' AND
         [TYPE] LIKE '%someChars%'));

PS:括号不是必须的

于 2013-07-25T13:31:06.540 回答
0
SELECT *
FROM myTable
WHERE
  NAME LIKE '%someChars%' AND
  CITY LIKE '%someChars%' AND
  TYPE LIKE '%someChars%';
于 2013-07-25T13:29:12.270 回答