Q: How to get data with order by id in MySQL I want to show data from database if status is enable and package type is domestic and order by id desc. Here is my code:
$sql = "select * 
        from holidays 
        where pkg_status = 'Enable' 
          and pkg_type = 'Domestic' 
        limit 6";

I want to show this data as order by id desc. When I am trying to add query like this, it is not working.
$sql = "select * 
        from holidays 
        where pkg_status = 'Enable' 
          and pkg_type = 'Domestic' 
        limit 6 
        order by id desc";

Please help me.

A: limit is always written after group clause in SQL

A: Here you go, just copy and paste, you will be fine :
SELECT * FROM holidays
   WHERE pkg_status='Enable'
   AND pkg_type = 'Domestic'
   ORDER BY id DESC LIMIT 6;

