how to sort order of LEFT JOIN in SQL query?

后端 未结 5 1668
悲哀的现实
悲哀的现实 2020-12-08 04:25

OK I tried googling for an answer like crazy, but I couldn\'t resolve this, so I hope someone will be able to help.

Let\'s say I have a table of users, very simple t

5条回答
  •  误落风尘
    2020-12-08 05:06

    try this out:

       SELECT
          `userName`,
          `carPrice`
       FROM `users`
       LEFT JOIN `cars`
       ON cars.belongsToUser=users.id
       WHERE `id`='4'
       ORDER BY `carPrice` DESC
       LIMIT 1
    

    Felix

提交回复
热议问题