0

I wanna make tringger, so after inserting data, the datas ordered by date (here name 'tanggal')

but got error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY tanggal ASC; END' at line 5

DELIMITER $$
CREATE TRIGGER sort_by_tanggal
AFTER INSERT ON laporan_bukubesar 
    FOR EACH ROW
BEGIN
    ALTER TABLE laporan_bukubesar ORDER BY tanggal ASC;
END $$
DELIMITER ;
fahmi zikrul
  • 7
  • 1
  • 5
  • you can not do that in a trigger – nbk Aug 02 '20 at 11:21
  • What storage engine laporan_bukubesar ? – P.Salmon Aug 02 '20 at 11:25
  • @P.Salmon MySql sir – fahmi zikrul Aug 02 '20 at 11:56
  • @nbk is there any way to do the same like that? im using 3 tables and combine it into one table, but i need to arrange by date – fahmi zikrul Aug 02 '20 at 11:58
  • not really tables are per definition unsorted, so imposing an order, makes not that much sense, besides ordering the hole table costs tome, and it will be run after **every ** row. which makes even less sens. run your insert and after that make your alter Table, if you still want to – nbk Aug 02 '20 at 12:03

0 Answers0