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;