请帮帮我
SELECT mainmenu.mid FROM (
(
SELECT
content_info.ContentID,
content_info.Title,
menu_list_article.MenuID as article_parent,
subsubmenu.title as article_parent_title,
submenu.sid,
submenu.title as sid_title,
mainmenu.mid,
mainmenu.title as mid_title,
mainmenu.module
FROM `content_info`
JOIN menu_list_article ON menu_list_article.ContentID = content_info.ContentID
JOIN subsubmenu ON subsubmenu.ssid=menu_list_article.MenuID
JOIN submenu ON submenu.sid=subsubmenu.sid
JOIN mainmenu ON mainmenu.mid=submenu.mid
WHERE menu_list_article.MenuID LIKE 'SSMN%'
) UNION
(
SELECT
content_info.ContentID,
content_info.Title,
menu_list_article.MenuID as article_parent,
submenu.title as article_parent_title,
mainmenu.mid,
mainmenu.title as mid_title,
mainmenu.module
FROM `content_info`
JOIN menu_list_article ON menu_list_article.ContentID = content_info.ContentID
JOIN submenu ON submenu.sid=menu_list_article.MenuID
JOIN mainmenu ON mainmenu.mid=submenu.mid
WHERE menu_list_article.MenuID LIKE 'SMN%'
)
)
WHERE mainmenu.mid='MN-0053'
答案 0 :(得分:0)
我会有机会回答这个“问题”:
SELECT
content_info.ContentID,
content_info.Title,
menu_list_article.MenuID as article_parent,
submenu.title as article_parent_title,
mainmenu.mid,
mainmenu.title as mid_title,
mainmenu.module
FROM `content_info`
INNER JOIN menu_list_article ON menu_list_article.ContentID = content_info.ContentID
INNER JOIN submenu ON submenu.sid=menu_list_article.MenuID
INNER JOIN mainmenu ON mainmenu.mid=submenu.mid
WHERE menu_list_article.MenuID LIKE 'SSMN%' and mainmenu.mid='MN-0053'
UNION
SELECT
content_info.ContentID,
content_info.Title,
menu_list_article.MenuID as article_parent,
submenu.title as article_parent_title,
mainmenu.mid,
mainmenu.title as mid_title,
mainmenu.module
FROM `content_info`
INNER JOIN menu_list_article ON menu_list_article.ContentID = content_info.ContentID
INNER JOIN submenu ON submenu.sid=menu_list_article.MenuID
INNER JOIN mainmenu ON mainmenu.mid=submenu.mid
WHERE menu_list_article.MenuID LIKE 'SMN%' and mainmenu.mid='MN-0053'
没有理由在第一个查询中有子选择,我将最外面的标准移动到2个查询中,并且我将连接定义为内部连接(您可能必须根据您的要求使用左或右连接,但我猜不出那些。)
下次请描述您的问题,并向我们提供有关该任务的更多背景信息。