SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/07/2017, 10:24 PM   #1
saffierr
High-roller
 
saffierr's Avatar
 
Join Date: Jul 2013
Location: GetPlayerGirlHouse(targetplayer);
Posts: 1,157
Reputation: 36
Default insert a row

I was wondering if it is actually possible to insert a row on top of the table, using MySQL.
PHP Code:
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.
saffierr is offline   Reply With Quote
Old 17/07/2017, 10:27 PM   #2
Eoussama
Gangsta
 
Eoussama's Avatar
 
Join Date: Jul 2016
Location: Kingdom of Morocco // Tangier
Posts: 916
Reputation: 124
Default Re: insert a row

****** my friend, use ******,
check this link, it has some interesting tips
__________________
Eoussama is offline   Reply With Quote
Old 17/07/2017, 10:37 PM   #3
saffierr
High-roller
 
saffierr's Avatar
 
Join Date: Jul 2013
Location: GetPlayerGirlHouse(targetplayer);
Posts: 1,157
Reputation: 36
Default Re: insert a row

I see, I'm still confused on how the query should look like, an example would be appreciated.
saffierr is offline   Reply With Quote
Old 17/07/2017, 10:46 PM   #4
Paulice
Huge Clucker
 
Paulice's Avatar
 
Join Date: Jul 2017
Posts: 492
Reputation: 42
Default Re: insert a row

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
Paulice is offline   Reply With Quote
Old 17/07/2017, 11:26 PM   #5
saffierr
High-roller
 
saffierr's Avatar
 
Join Date: Jul 2013
Location: GetPlayerGirlHouse(targetplayer);
Posts: 1,157
Reputation: 36
Default Re: insert a row

Makes sense, thanks.
saffierr is offline   Reply With Quote
Old 18/07/2017, 05:36 AM   #6
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 11,086
Reputation: 2647
Default Re: insert a row

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.
__________________
Vince is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert into MerryDeer Scripting Help 1 22/08/2016 06:11 PM
Can anyone tell me why this won't insert? Ox1gEN Scripting Help 2 31/08/2014 04:53 AM
How to insert? Dziugsas Scripting Help 11 18/05/2012 11:32 AM
Insert bug. Neavorce Bug Reports 3 11/03/2012 09:28 PM
/veh [INSERT NAME HERE] ViruZZzZ_ChiLLL Help Archive 3 01/05/2010 02:12 PM


All times are GMT. The time now is 02:50 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.