locked
select statement, inner join, order by Id desc RRS feed

  • Question

  • User-1290459327 posted

    Dear mySQL-ers,

    I have make a MySql Query,

    Tis query works fine withoud the  "ORDER BY verhaal.Id DESC" is it possible to use this when i have use a INNER JOIN.

    Can someone give me some advice

    Here is my Query witch working fine,

    Select verhaal.Id, verhaal.Text, verhaal.Name, verhaal.Date, users.Avatar
    from verhaal
    INNER JOIN users
    WHERE users.Name = verhaal.name

    Here is the query what i neeed but not will works,

    Select verhaal.Id, verhaal.Text, verhaal.Name, verhaal.Date, users.Avatar 
    from verhaal
    ORDER BY verhaal.Id DESC
    INNER JOIN users WHERE users.Name = verhaal.name

    It gives a result of,

    "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN users WHERE users.Name = verhaal.name' at line 1 "

    Tuesday, May 7, 2013 6:05 PM

Answers

  • User1519811487 posted
    Hi The order by needs to be after the where statement. Thanks
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 7, 2013 6:11 PM
  • User-1716253493 posted
    select... ORDER BY verhaal. Id DESC;
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 7, 2013 6:45 PM

All replies

  • User1519811487 posted
    Hi The order by needs to be after the where statement. Thanks
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 7, 2013 6:11 PM
  • User-1716253493 posted
    select... ORDER BY verhaal. Id DESC;
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 7, 2013 6:45 PM
  • User-1290459327 posted

    Hi both replyers,

    sorry for this late answer,

    I was on vacation. Thans for the reply it is working, i aswer both as aswer

    Sunday, May 12, 2013 3:45 PM