LIMIT 1
#1

What does Limit 1 mean in MQSQL??


UPDATE `user` SET TimeLost=%d WHERE `UserName` = '%e' LIMIT 1 - Limit 1

??
Reply
#2

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.
Reply
#3

should I leave it there or delete each Limit 1?? I have it at OnPlayerUpdateEx
Reply
#4

https://sampforum.blast.hk/showthread.php?tid=609261 i just made this tutorial and you asked for it
Reply
#5

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.
Reply
#6

Quote:
Originally Posted by Chilli9434
View Post
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..
Reply
#7

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).
Reply
#8

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)