Mysql Experts, take a look please. -
Ronaldo_raul™ - 16.09.2012
Hello, I've been scripting in MySQL since 3 days. I've learnt the basic things, but now I want to expertise my MySQL coding skills. Since, MySQL is a great saving system, I am finding ways to expertise it. What I want to know is what silly mistakes people makes that aren't to be made. So, basically can anyone give me a guide through how can I optimise my MySQL codes. How to and where to properly use some functions like -
and another things like -
should we really do things like this -
pawn Код:
mysql_query ( "UPDATE `user` SET a=1 , b=2 WHERE `Name` = '%s'" ) ;
OR
pawn Код:
mysql_query ( "UPDATE user SET a=1 , b=2 WHERE Name = '%s'" ) ;
Where to use [
``] and where not to ?
Maybe a deep knowledge and guide can help me.
Thank you.
Obediently,
Ronaldo_raul
Re: Mysql Experts, take a look please. -
Vince - 16.09.2012
1. You only need to free a result if you have stored one in the first place (mysql_store_result), so usually only after SELECT queries.
2. You only need to use backticks if the table or column name is a MySQL keyword.
Re: Mysql Experts, take a look please. -
Ronaldo_raul™ - 16.09.2012
Quote:
Originally Posted by Vince
1. You only need to free a result if you have stored one in the first place (mysql_store_result), so usually only after SELECT queries.
2. You only need to use backticks if the table or column name is a MySQL keyword.
|
Thank you.
erm, about the second answer. Keyword ? I don't get it. Can you give me some precise examples ?
Thank you once again for the quick reply.
I am being so impatient to know more about optimizations. Can you point out some tricks ?
Re: Mysql Experts, take a look please. -
Vince - 16.09.2012
http://dev.mysql.com/doc/refman/5.0/...ved-words.html
Re: Mysql Experts, take a look please. -
Ronaldo_raul™ - 16.09.2012
Quote:
Originally Posted by Vince
|
I saw it. But confused
Help.
Re: Mysql Experts, take a look please. -
Sinner - 16.09.2012
Quote:
Originally Posted by Ronaldo_raul™
I saw it. But confused
Help.
|
Reserved words/keywords are just words already used by MySQL (like "update", "insert", "table", "change", etc...).
In most cases you won't even need to use backticks.
Re: Mysql Experts, take a look please. -
Ronaldo_raul™ - 16.09.2012
Quote:
Originally Posted by Sinner
Reserved words/keywords are just words already used by MySQL (like "update", "insert", "table", "change", etc...).
In most cases you won't even need to use backticks.
|
AHA!
Got it, thank you. But I've seen many users doing -
pawn Код:
mysql_query( "SELECT `users` SET a=1, ...... ) ;
Seems that's the wrong way.
I've PM'ed you regarding some questions, please check it out.
Re: Mysql Experts, take a look please. -
ReneG - 16.09.2012
Also, since you're just learning MySQL, learn how to use the threaded queries, with the cache. It still surprises me why some people are still using methods R6 and below, it's also faster, and easier IMO
Re: Mysql Experts, take a look please. -
Ronaldo_raul™ - 17.09.2012
Quote:
Originally Posted by VincentDunn
Also, since you're just learning MySQL, learn how to use the threaded queries, with the cache. It still surprises me why some people are still using methods R6 and below, it's also faster, and easier IMO
|
Ah, Yes. Thank you.
+reps for you all.
NOTE: Topic or discussion didn't end. I want more suggestions and knowledge.
Re: Mysql Experts, take a look please. - Emmet_ - 17.09.2012
There are some words that are reserved by MySQL, so doing this:
pawn Код:
mysql_query("UPDATE `accounts` SET Points = '50' ...");
Wouldn't work. Why? The word Po
ints contains a word (int) which is reserved by MySQL.
Therefore, that query won't be executed, and an error will be logged into mysql_log.txt.
Here's the correct way:
pawn Код:
mysql_query("UPDATE `accounts` SET `Points` = '50' ...");
You must include the backtick character before and after a table/field name.