LIMIT 1 - 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: LIMIT 1 (
/showthread.php?tid=609334)
LIMIT 1 -
Ugaustin - 11.06.2016
What does Limit 1 mean in MQSQL??
UPDATE `user` SET TimeLost=%d WHERE `UserName` = '%e' LIMIT 1 - Limit 1
??
Re: LIMIT 1 -
Vince - 11.06.2016
Means that it will only update the first row it finds. If your username column is set as unique, which it should be, then that condition is completely redundant. Same for select statements.
Re: LIMIT 1 -
Ugaustin - 11.06.2016
should I leave it there or delete each Limit 1?? I have it at OnPlayerUpdateEx
Re: LIMIT 1 -
SyS - 11.06.2016
https://sampforum.blast.hk/showthread.php?tid=609261 i just made this tutorial and you asked for it
Re: LIMIT 1 -
Chilli9434 - 11.06.2016
LIMIT 1 should be fine for this particular query, its hard to say since you didn't give us any context in terms of the code it surrounds.
Re: LIMIT 1 -
Ugaustin - 11.06.2016
Quote:
Originally Posted by Chilli9434
LIMIT 1 should be fine for this particular query, its hard to say since you didn't give us any context in terms of the code it surrounds.
|
it's how much time he is connected..
Re: LIMIT 1 -
d1git - 11.06.2016
No need to have LIMIT 1 for this particular query, I doubt you'll have multiple rows with the same username in your users table.
Basically what Vince said, the username column should be unique (no duplicates).
Re: LIMIT 1 -
Stinged - 11.06.2016
Just like Vince said, it means it will only update the first row it finds.
I'll give an example using a picture:
Code:
UPDATE table_name SET Level = 500 WHERE Name = 'John' LIMIT 2
This will set the level of the first 2 to 500.
Code:
UPDATE table_name SET Level = 100 WHERE Name = 'John'
This will set the level of all of the rows that have John as name.