Re: Re: PHP and MySQL SELECT COUNT (*)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




1: SQL
in mysql queries /should/ use backticks (`) around database, table and column names, stop's them getting confused with variables or reserved words (like timestamp) and saves you future trouble :)

.. which is a mysql-ism - no other database supports this. As soon as you need to use another db (regardless of whether it's this application or not), you're stuffed.

For reserved word column names, you don't have much choice but don't do that in the first place ;)

http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

Other db's will have a similar list - though in most cases, if it's a function or sql keyword (eg 'table'), it'll be reserved in all.

further, you'll be needing to use AS to turn COUNT(steps) into a nice name like "stepcount"

Which is also a mysql-ism. Most other db's don't let you use aggregate aliases in an order by clause (I think because the sql standard says don't do that).

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux