Question for mysql
#1

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);
Reply
#2

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");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)