【发布时间】:2021-01-16 02:56:10
【问题描述】:
作为我previous question的后续行动:
我想选择wp_posts 表中匹配的所有内容:
post_type = "answer"post_type = "question"- post_type 包含修订,前面是前面任一标准的 ID。例如:
21-revision-v1或10903-revision-v1此处我要选择那些帖子的第一个数字部分与前2个要求中选择的帖子的ID匹配的帖子。
我现在构建了一个新表 ap_qa,其中包含符合上述条件 1 或 2 的帖子的所有 ID。
现在选择符合条件 3 的案例,我想使用 Substring_Index(),因为它允许在字符串中进行匹配。
我当前的代码是:
SELECT *
FROM `wp_posts` p
WHERE p.post_type IN ('answer', 'question') OR
Substring_Index(p.post_Type,'-revision',1) IN QA.ID
where 后面的第一条规则是满足条件 1 和 2,最后一行是满足条件 3。但是我的语法是无效的,正如返回的那样。
错误信息如下(荷兰语):
#1064 - Er is iets fout in de gebruikte syntax bij 'QA.ID' in regel 4
【问题讨论】:
标签: mysql sql select subquery where-clause