php里如何将多表关联后的sql添加序号?请大神帮忙解答一下,谢谢!

select a*,b.xxx from table_name1 a left join table_name2 b on a.id = b.id;
2024-12-05 07:10:35
推荐回答(1个)
回答(1):

SELECT a*,b.xxx,@rowNum:=@rowNum+1 AS rowNum FROM (SELECT @rowNum:=0) r,table_name1 a LEFT JOIN table_name2 b on a.id = b.id;