SELECT `bio_community_events`.`id`,
`bio_community_events`.`begin_on`,
`bio_community_events`.`name`
FROM `bio_community_events`
JOIN `bio_contacts`
ON (`bio_contacts`.`contact_id` = `bio_community_events`.`user_id`)
JOIN `bio_community_groups`
ON (`bio_community_groups`.`id` = `bio_community_events`.`group_id`)
WHERE `bio_contacts`.`user_id` = '33'
WHERE `bio_community_events`.`group_id` = '1'
LIMIT 10
UNION ALL
SELECT `bio_community_events`.`id`,
`bio_community_events`.`begin_on`,
`bio_community_events`.`name`
FROM `bio_community_events`
JOIN `bio_contacts`
ON (`bio_contacts`.`user_id` = `bio_community_events`.`user_id`)
JOIN `bio_community_groups`
ON (`bio_community_groups`.`id` = `bio_community_events`.`group_id`)
WHERE `bio_contacts`.`contact_id` = '33'
WHERE `bio_community_events`.`group_id` = '1'
LIMIT 10
[错误] 1064 - 你在你的 SQL语法错误;检查手册, 对应于您的MySQL服务器 版本的正确语法使用 'WHERE
bio_community_events
'附近。group_id
= '1'
我找不到语法错误!
编辑:
我包都变成支架,并添加 “在哪儿”。不工作...仍然是同样的错误。
新建查询:
SELECT `bio_community_events`.`id`,
`bio_community_events`.`begin_on`,
`bio_community_events`.`name`
FROM `bio_community_events`
JOIN `bio_contacts`
ON (`bio_contacts`.`contact_id` = `bio_community_events`.`user_id`)
JOIN `bio_community_groups`
ON (`bio_community_groups`.`id` = `bio_community_events`.`group_id`)
WHERE (`bio_contacts`.`user_id` = '33')
AND WHERE (`bio_community_events`.`group_id` = '1')
LIMIT 10
UNION ALL
SELECT `bio_community_events`.`id`,
`bio_community_events`.`begin_on`,
`bio_community_events`.`name`
FROM `bio_community_events`
JOIN `bio_contacts`
ON (`bio_contacts`.`user_id` = `bio_community_events`.`user_id`)
JOIN `bio_community_groups`
ON (`bio_community_groups`.`id` = `bio_community_events`.`group_id`)
WHERE (`bio_contacts`.`contact_id` = '33')
AND WHERE (`bio_community_events`.`group_id` = '1')
LIMIT 10
编辑#2:
我看着你的榜样。愚蠢的我!谢谢。
线索在问题中,实际上是问题的标题! ;-) –
给你编辑:你只需要一个'WHERE',就像我的答案中的例子。 – Jacob