为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
- 【TiDB 版本】:3.0.7
- 【问题描述】:
TiDB 下报错:
mysql> insert into topic_views (topic_id, ip_address, viewed_at, user_id) select 18, '203.208.*.*', '2019-12-31', 712 where not exists (select 1 from topic_views where user_id = 712 and topic_id = 62283);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 120 near "where not exists (select 1 from topic_views where user_id = 712 and topic_id = 62283)"
MySQL 执行成功:
mysql> insert into topic_views (topic_id, ip_address, viewed_at, user_id) select 18, '203.208.*.*', '2019-12-31', 7 where not exists (select 1 from topic_views where user_id = 7 and topic_id = 62283);
Query OK, 1 row affected (0.01 sec)
Records: 1 Duplicates: 0 Warnings: 0
表结构:
CREATE TABLE `topic_views` (
`topic_id` int(11) NOT NULL,
`viewed_at` date NOT NULL,
`user_id` int(11) DEFAULT NULL,
`ip_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
UNIQUE KEY `uniq_ip_or_user_id_topic_views` (`user_id`,`ip_address`,`topic_id`),
KEY `index_topic_views_on_topic_id_and_viewed_at` (`topic_id`,`viewed_at`),
KEY `index_topic_views_on_user_id_and_viewed_at` (`user_id`,`viewed_at`),
KEY `index_topic_views_on_viewed_at_and_topic_id` (`viewed_at`,`topic_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
请问是什么原因