SA-MP Forums Archive
insert a row - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: insert a row (/showthread.php?tid=637593)



insert a row - saffierr - 17.07.2017

I was wondering if it is actually possible to insert a row on top of the table, using MySQL.
PHP код:
INSERT INTO 
inserts a row at the bottom of the table, though I was wondering if it is possible to add a row on top of the table.


Re: insert a row - Eoussama - 17.07.2017

****** my friend, use ******,
check this link, it has some interesting tips


Re: insert a row - saffierr - 17.07.2017

I see, I'm still confused on how the query should look like, an example would be appreciated.


Re: insert a row - Paulice - 17.07.2017

Of course it's possible. When auto increment is enabled (which should always be) on a table, rows are ordered by their SQL ID (the ID given by auto increment).

I'm not sure why you want to do this, unless it's for organization/grouping purposes. However, follow these guidelines:
  1. UPDATE all existing row IDs by 1 ** `sql_id` + 1 **
  2. INSERT the new row INTO the table, setting the SQL ID to 1
  3. Increase the table's auto increment value by 1



Re: insert a row - saffierr - 17.07.2017

Makes sense, thanks.


Re: insert a row - Vince - 18.07.2017

The "top" of the table is relative because it is determined by the way the results are ordered. A surrogate primary key should never be altered once set.