Re: [PHP] From: Newman, using " and ' or ` in My Sql
On Sat, 16 Mar 2002, Philip J. Newman wrote: > A few of us folk at PhilipNZ.com would like to know about using " and ' or ` in My >Sql when calling information from the database. > > we have always used > > $sql = "SELECT * FROM `hyperlinks` ORDER BY `clicks` DESC LIMIT 0, 10"; > > but where told that the ` was not required > > $sql = "SELECT * FROM hyperlinks ORDER BY clicks DESC LIMIT 0, 10"; The backtick (`) has an entirely different meaning and shouldn't be used to delimit arguments in MYSQL statements. It's used to indicate that you want to execute a command external to PHP (for instance, `/bin/ls`). The standard quote (') should be used to delimit string literals in MYSQL statements. Use it to surround strings you're inserting into or comparing against VARCHARs, CHARs, TEXTs, etc. Both are unnecessary in the statements you cite above. Here's a simple statement using the standard single quote: $sql = "UPDATE mytable SET name='Best Table Of All' WHERE id=3"; miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] From: Newman, using " and ' or ` in My Sql
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says... > On Saturday 16 March 2002 13:08, Philip J. Newman wrote: > > A few of us folk at PhilipNZ.com would like to know about using " and ' or > > ` in My Sql when calling information from the database. > > > > we have always used > > > > $sql = "SELECT * FROM `hyperlinks` ORDER BY `clicks` DESC LIMIT 0, 10"; > > > > but where told that the ` was not required > > > > $sql = "SELECT * FROM hyperlinks ORDER BY clicks DESC LIMIT 0, 10"; > > > > Any Comments on this? > > Yes, this should be posted to php-db. > > For simple cases ` ` are not needed. It is only used if your column names > contain weird characters, spaces for instance, then: > > SELECT `First Name` FROM Address; And of course single quotes (') should be used to delimit text data being inserted into CHAR type fields. But you knew that, of course. -- David Robley Temporary Kiwi! Quod subigo farinam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] From: Newman, using " and ' or ` in My Sql
On Saturday 16 March 2002 13:08, Philip J. Newman wrote: > A few of us folk at PhilipNZ.com would like to know about using " and ' or > ` in My Sql when calling information from the database. > > we have always used > > $sql = "SELECT * FROM `hyperlinks` ORDER BY `clicks` DESC LIMIT 0, 10"; > > but where told that the ` was not required > > $sql = "SELECT * FROM hyperlinks ORDER BY clicks DESC LIMIT 0, 10"; > > Any Comments on this? Yes, this should be posted to php-db. For simple cases ` ` are not needed. It is only used if your column names contain weird characters, spaces for instance, then: SELECT `First Name` FROM Address; -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* A domineering man married a mere wisp of a girl. He came back from his honeymoon a chastened man. He'd become aware of the will of the wisp. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php