这样写试试: select a.name as name ,a.email as email from email a union select a.name as naem ,a.email as email from emailhand a
我仔细看了题目的SQL,它有明显的错误 在后半句。 你要从emailhand表中取email表中的字段。当然不正确。 你可以写成 select Email.name as nameA,email.email as email,emailhand.name as nameB from email,emailhand from email,emailhand where emailhand.email=email.email
不好意思,是我太粗心了,其实我的意思就是要 select email.email,email.name from email union select emailhand.email,emailhand.name from emailhand
以上答案全部错误: select email.email,email.name from email union all select emailhand.email,emailhand.name from emailhand order by 1关键两点:(union all) and (order by 1)
select a.name as name ,a.email as email from email a
union
select a.name as naem ,a.email as email from emailhand a
在后半句。
你要从emailhand表中取email表中的字段。当然不正确。
你可以写成
select Email.name as nameA,email.email as email,emailhand.name as nameB from
email,emailhand from email,emailhand where emailhand.email=email.email
select email.email,email.name from email
union
select emailhand.email,emailhand.name from emailhand
select email.email,email.name from email
union all
select emailhand.email,emailhand.name from emailhand
order by 1关键两点:(union all) and (order by 1)