为什么选择语法不起作用

时间:2018-08-08 10:27:54

标签: mysql-error-1064

我不明白为什么在以下查询中做错了。

WITH t1 (card_num) as (SELECT b.card_num FROM bills AS b WHERE date(b.sls_date) >= '2017-07-31' AND date(b.sls_date) <= '2018-07-31' GROUP BY b.card_num)
SELECT c.lastname, c.firstname FROM contacts AS c WHERE id_client in(SELECT bc.id_client FROM bonus_cards AS bc WHERE bc.card_num in(t1) AND bc.card_new in(t1) GROUP BY bc.id_client) and c.phone_mobile is not null AND c.email is not null AND TRIM(IFNULL(c.email,'')) <> '' AND TRIM(IFNULL(c.phone_mobile,'')) <> '' AND c.sex = '0' limit 10;

我明白了-

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't1 (card_num) as (select b.card_num from api_bills as b where date(b.sls_date) >' at line 1

但是我知道语法正确,还是我弄错了?

0 个答案:

没有答案