Tam McLaughlin wrote:

i am trying something in mysql but can't remember any sql.
Say i have a field called name in table 1 and i want to select the
name and the number of times that name appears in the table,
how would i do it?
If u can tell me, i can find the equiv syntax in mysql
thanks.

Ignoring the fact that you can't have a table called '1', since field names have to be unique, once. If you mean how many times the field called 'name' has a specific value:

SELECT name, COUNT(*) FROM table1 GROUP BY 1;

If you just want the unique values for 'name' then its more efficient to do:

SELECT DISTINCT name FROM table1;

If you want the detailled records where 'name' has a specific value then:

SELECT * FROM table1 WHERE name='Fred';

I must confess that I learnt much of my SQL from MS-Access by switching between the QBE and SQL views, although it tends to overgenerous with its use of ((((((brackets))))))) and Access.tablenames. And of course its Microsoft Jet SQL which isn't even the same as the SQL in MS SQL server and ....

Tried Devshed for a SQL tutorial?

Colin


_______________________________________________
Scottish mailing list
[EMAIL PROTECTED]
http://mailman.lug.org.uk/mailman/listinfo/scottish


Reply via email to