SA-MP Forums Archive
Question for mysql - 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: Question for mysql (/showthread.php?tid=309006)



Question for mysql - Tanush123 - 05.01.2012

What does Limit 1 does for mysql? Which is the correct way?

pawn Код:
format(str,sizeof(str),"UPDATE orgs SET Color1 = %d, Color2 = %d WHERE Orgid = %d LIMIT 1",ccol1,ccol2,orgid);
or
pawn Код:
format(str,sizeof(str),"UPDATE orgs SET Color1 = %d, Color2 = %d WHERE Orgid = %d",ccol1,ccol2,orgid);



Re: Question for mysql - jamiesage123 - 05.01.2012

Using 'LIMIT' limits the number of rows returned.

In my opinion, LIMIT is only useful when selecting data from a mysql table. There is no point in limiting something which you know will only exist once in the table (...then again, if you have more than one result with the same field name, you might want to use LIMIT).

pawn Код:
format(str,sizeof(str),"SELECT * FROM orgs WHERE Orgid = '%d' LIMIT 1", orgid);
A better example of that would be if you want to retrieve the first 5 rows where someones age is 22.

pawn Код:
format(str,sizeof(str),"SELECT * FROM people WHERE age = '22' LIMIT 5");