SA-MP Forums Archive
MySQL issue - 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: MySQL issue (/showthread.php?tid=379041)



MySQL issue - Speed++ - 20.09.2012

my question is, when and when not to use in a query the symbol ` `

and

what is the / and when and when not to use ORDER BY and the LIMIT in a query


Re: MySQL issue - mamorunl - 20.09.2012

You use the accents when you are not sure if your table name or column name is a MYSQL Reserved word

ORDER BY: Sets the order of the items sorted alphabetically (so: mamoru comes before Zen in a ORDER BY ASC)
LIMIT: Limits the number of records returned (eg: SELECT * FROM users LIMIT 0,10 gets the first 10 users in the table)


Re: MySQL issue - Speed++ - 20.09.2012

Quote:
Originally Posted by mamorunl
Посмотреть сообщение
You use the accents when you are not sure if your table name or column name is a MYSQL Reserved word

ORDER BY: Sets the order of the items sorted alphabetically (so: mamoru comes before Zen in a ORDER BY ASC)
LIMIT: Limits the number of records returned (eg: SELECT * FROM users LIMIT 0,10 gets the first 10 users in the table)
OK, thanks

i don't understand the accents... explain more


Re: MySQL issue - Vince - 20.09.2012

http://forum.sa-mp.com/showthread.ph...=mysql+keyword


Re: MySQL issue - mamorunl - 20.09.2012

Quote:
Originally Posted by Speed++
Посмотреть сообщение
OK, thanks

i don't understand the accents... explain more
Vince has posted a nice thread, but to put it in short: you put an accent to the column or table name if you are not sure if it is a mysql keyword (or reserved word). These are words that you put into your query to get the result you want: SELECT, IN, IS, NOT, WHERE, HAVING, etc. If you do want these as a table name (which I had in a project once, which were IS-parts) you have to 'escape' the table names with those back ticks. So:

SELECT * FROM `IS` WHERE 1=1

SELECT * FROM IS WHERE 1=1 will give an error.