1. 一句话实现Mysql查询结果带行号
SELECT @rowno:=@rowno+1 AS rowno,a.id,a.`status`,a.reason FROM e_four_auth a,(SELECT @rowno:=0) b
(SELECT @rowno:=0) 初始化rowno ; @rowno:=@rowno+1 每行+1
2.explain 用法和结果的含义
1 inner join : SELECT * FROM TableA INNER JOIN TableB ON TableA.name = TableB.name
交集
2 left join : SELECT * FROM TableA LEFT JOIN TableB ON TableA.name = TableB.name
A的完全集,B中能匹配的则有值,没有匹配的则null. (right left类似。不写了)
SELECT * FROM TableA LEFT JOIN TableB ON TableA.name = TableB.name WHERE TableB.id IS NULL;
A中有,B中没有的
网友评论