Last active
May 15, 2018 07:59
-
-
Save ajaxray/4ba0d9e2700d561e2bb00a39e35a61da to your computer and use it in GitHub Desktop.
Adding row sequence number to MySQl result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
@a:=@a+1 AS sl, | |
t.field_name, | |
ot.other_field_name, | |
-- more fields... | |
FROM | |
(SELECT @a:= 0) AS a, | |
primary_table_name t | |
JOIN other_table ot ON t.other_id = ot.id | |
WHERE | |
-- conditions... | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment