Версия сервера: 8.0.19 MySQL Сервер совместной работы
У меня есть 2 таблицы: Channel и User_message.
mysql> describe Channel;
+--------------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+------+------+-----+---------+-------+
| channel_id | int | NO | PRI | NULL | |
| channel_name | text | NO | | NULL | |
+--------------+------+------+-----+---------+-------+
mysql> describe User_message;
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| message_id | varchar(255) | NO | PRI | NULL | |
| channel_id | int | NO | MUL | NULL | |
| user_id | int | NO | | NULL | |
| timestamp | float | NO | | NULL | |
+------------+--------------+------+-----+---------+-------+
Я пытаюсь использовать выражение CTE, например:
WITH `vals` (`uid`, `cid`) AS (VALUES (816, 97), (1, 97), (754, 10)) SELECT `t1`.`message_id`, `t1`.`channel_id`, `t1`.`user_id`, `t1`.`timestamp` FROM `User_message` AS `t1` INNER JOIN `vals` ON ((`t1`.`user_id` = `vals`.`uid`) AND (`t1`.`channel_id` = `vals`.`cid`));
Но я получаю эту ошибку:
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 '(816, 97), (1, 97), (754, 10)) SELECT `t1`.`message_id`, `t1`.`channel_id`, `t1`' at line 1
Хотя этот запрос отлично работает с SQLite, почему?