Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order by in Inner Join

Tags:

I am putting inner join in my query.I have got the result but didn't know that how the data is coming in output.Can anyone tell me that how the Inner join matching the data.Below I am showing a image.There are two table(One or Two Table).

alt text

According to me that first row it should be Mohit but output is different.Please tell me.

Thanks in advance.

like image 831
Mohit Kumar Avatar asked Nov 01 '10 14:11

Mohit Kumar


1 Answers

In SQL, the order of the output is not defined unless you specify it in the ORDER BY clause.

Try this:

SELECT  *
FROM    one
JOIN    two
ON      one.one_name = two.one_name
ORDER BY
        one.id
like image 98
Quassnoi Avatar answered Nov 18 '22 03:11

Quassnoi