MySQL Forums
Forum List  »  Docs

Re: I need help for Error :1062
Posted by: Jonathan Stephens
Date: May 19, 2005 06:27PM

> SELECT cognome, count(1)
> FROM tbl_seba
> #where seba.cognome in ('bellu','mannu')
> where cognome = 'bellu' or cognome = 'mannu'
> group by 1

'COUNT(1)' and 'GROUP BY 1' make no sense. I tried this using mySQL 5.0.4-beta-nt-max and it worked without any errors. But the result doesn't really mean anything. These constructs are used properly with column names, not with values.

I think perhaps this is what you intended:

SELECT cognome, COUNT(cognome) AS num
FROM tbl_seba
WHERE cognome IN ('bellu', 'mannu')
GROUP BY cognome

This query returns

| cognome | num |
| bellu | 3 |
| mannu | 3 |

(Also, why the COMMIT statement? If you're using a MyISAM table, it's not necessary. In MyISAM, all data manipulation statements are committed as soon as they're executed.)

In future, please use this area of the forums for questions relating to the MySQL Manual or other MySQL documentation. Questions about using MySQL should go in the appropriate area. Thanks!

Jon Stephens
MySQL Documentation Team @ Oracle

MySQL Dev Zone
MySQL Server Documentation
Oracle

Options: ReplyQuote


Subject
Views
Written By
Posted
11744
April 28, 2005 09:22AM
Re: I need help for Error :1062
4782
May 19, 2005 06:27PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.