Order by in Inner Join

后端 未结 6 784
难免孤独
难免孤独 2021-02-18 16:28

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.Bel

6条回答
  •  隐瞒了意图╮
    2021-02-18 17:22

    SQL doesn't return any ordering by default because it's faster this way. It doesn't have to go through your data first and then decide what to do.

    You need to add an order by clause, and probably order by which ever ID you expect. (There's a duplicate of names, thus I'd assume you want One.ID)

    select * From one
    inner join two
    ON one.one_name = two.one_name
    ORDER BY one.ID
    

提交回复
热议问题