求一SQL语句。速度~~
table A
userid userip
1 192.168.1.1
null 192.168.1.15
2 192.168.1.13
4 192.168.1.19
null 192.168.1.18
table B
userid username grade
1 aa 2
2 bb 3
3 cc 4
4 dd 2
5 ee 6
要得到这样的结果
userid userip username grade
1 192.168.1.1 aa 2
null 192.168.1.15 null null
2 192.168.1.13 bb 3
4 192.168.1.19 dd 2
null 192.168.1.18 null null
------解决方案--------------------SELECT A.userid, A.userip, B.username, B.grade FROM table A
LEFT OUTER JOIN table B ON A.userid = B.userid
------解决方案--------------------try
Select A.*, B.username, B.grade From A
Left Join B
On A.userid = B.userid