È磺 µÚÒ»¸ö²éѯÓï¾äΪ£ºselect * from a µÚ¶þ¸ö²éѯÓï¾äΪ£ºselect * from b Ôò²¢ºÏÕâÁ½¸öÓï¾äµÄÓï¾äÊÇ·ñΪ£ºselect * from (select * from a,select * from b)??? ÕâÑùºÃÏñ²»¶Ô¡£Èç¹ûÁ½±íµÄ½á¹¹ÏàͬµÄ»° select * from a union all select * from b ºáÏòleft join ×ÝÏò union all SQL code: select * from a left join b on a.id=b.id
select * from a union all select * from b
Èç¹ûÁ½±í×Ö¶Î,ÀàÐÍÏàͬ. select * from a union all select * from b
Èç¹ûÁ½±í×Ö¶Î,ÀàÐͲ»Ïàͬ. ¸ü¸ÄÀàÐͺÍÃû³Æ. ÀýÈç:
select id , name ... from a union all select cast(bid as int) , bname as name ... from b
»òÕßÊÇ:
select a.* , b.* from a , b where a.¹Ø¼ü×Ö = b.¹Ø¼ü×Ö select a.* , b.* from a left join b on a.¹Ø¼ü×Ö = b.¹Ø¼ü×Ö