Using Union All and Order By in MySQL

前端 未结 2 1417
春和景丽
春和景丽 2021-01-19 03:50

I\'ve 2 tables:

create table advertised_products(id int,title varchar(99),timestamp timestamp);
insert advertised_products select 1,\'t1\',curdate();

create         


        
2条回答
  •  日久生厌
    2021-01-19 04:26

    Error lies in here,

     "ORDER BY timestamp desc limit 3"
    

    as you are combining the two tables query must know which fields are you using in which table.clearly that you are missing the table reference in your "orderby" clause

    mention the table name/alias of the table name like below

     "ORDER BY your_table_name.timestamp desc limit 3"
    

提交回复
热议问题