just give a it try select count(columnname) from table; Eric Bergen <[EMAIL PROTECTED]> wrote:select count(*) table; gives me a syntax error in 4.0 and 4.1 so I'm not sure how that worked. Something similar would be select count(*) t; which uses the shortcut alias syntax. It's the same as doing select count(*) as t;
Simon Garner wrote: > [EMAIL PROTECTED] wrote: > >> I have a curious situation I was hoping someone could shed some light >> on. >> >> mysql> select count(*) table; >> +-------+ >> | table | >> +-------+ >> | 0 | >> +-------+ >> 1 row in set (0.00 sec) >> >> mysql> select count(*) from table; >> +----------+ >> | count(*) | >> +----------+ >> | 25965 | >> +----------+ >> 1 row in set (0.00 sec) >> >> >> I found it curious that the first query didn't return an error with >> there being no 'from', and even more curious that it returned a 0. >> Is the first query actually legit, and if so, what does the 0 mean? > > > Yes, you can do a select without a table. This allows you to get the > values of expressions or functions. > > E.g. > > SELECT 1+1 > > will return 2, and > > SELECT NOW() > > will return the current date and time. > > Your query is selecting "COUNT(*) AS table" rather than "COUNT(*) FROM > table". Naturally, without a table, COUNT(*) will return 0. > > -Simon > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] --------------------------------- Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses.