求助:mysql单表查询了两个结果集,怎么合并成一个结果集?
SELECT*FROMfmo_question_infoWHEREquestion_stutas=100ORDERBYnumberLIMIT3SELECT*FROMfmo...
SELECT * FROM fmo_question_info WHERE question_stutas=100 ORDER BY number LIMIT 3
SELECT * FROM fmo_question_info WHERE question_stutas=30 ORDER BY number LIMIT 7
就是上面两个结果集
SELECT * FROM (
(SELECT question_id ,quedtion,option_1,option_2,option_3,option_4,correct_answer,question_stutas,number FROM fmo_question_info WHERE question_stutas=100 ORDER BY number LIMIT 3 )
UNION
( SELECT question_id ,quedtion,option_1,option_2,option_3,option_4,correct_answer,question_stutas,number FROM fmo_question_info WHERE question_stutas=30 ORDER BY number LIMIT 7 )
) WHERE 1=1
上面这一段是自己的,执行不行。
好吧,我自己搞定了,删除一点就行,
(SELECT question_id ,quedtion,option_1,option_2,option_3,option_4,correct_answer,question_stutas,number FROM fmo_question_info WHERE question_stutas=100 ORDER BY number LIMIT 3 )
UNION
( SELECT question_id ,quedtion,option_1,option_2,option_3,option_4,correct_answer,question_stutas,number FROM fmo_question_info WHERE question_stutas=30 ORDER BY number LIMIT 7 )
汗。。。。。。 展开
SELECT * FROM fmo_question_info WHERE question_stutas=30 ORDER BY number LIMIT 7
就是上面两个结果集
SELECT * FROM (
(SELECT question_id ,quedtion,option_1,option_2,option_3,option_4,correct_answer,question_stutas,number FROM fmo_question_info WHERE question_stutas=100 ORDER BY number LIMIT 3 )
UNION
( SELECT question_id ,quedtion,option_1,option_2,option_3,option_4,correct_answer,question_stutas,number FROM fmo_question_info WHERE question_stutas=30 ORDER BY number LIMIT 7 )
) WHERE 1=1
上面这一段是自己的,执行不行。
好吧,我自己搞定了,删除一点就行,
(SELECT question_id ,quedtion,option_1,option_2,option_3,option_4,correct_answer,question_stutas,number FROM fmo_question_info WHERE question_stutas=100 ORDER BY number LIMIT 3 )
UNION
( SELECT question_id ,quedtion,option_1,option_2,option_3,option_4,correct_answer,question_stutas,number FROM fmo_question_info WHERE question_stutas=30 ORDER BY number LIMIT 7 )
汗。。。。。。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询