I DISTINCTly hate MySQL (help building a query)

Posted by Alex Mcp on Stack Overflow See other posts from Stack Overflow or by Alex Mcp
Published on 2010-04-21T01:16:45Z Indexed on 2010/04/21 1:23 UTC
Read the original article Hit count: 255

Filed under:
|
|
|

This is staight forward I believe:

I have a table with 30,000 rows. When I SELECT DISTINCT 'location' FROM myTable it returns 21,000 rows, about what I'd expect, but it only returns that one column.

What I want is to move those to a new table, but the whole row for each match.

My best guess is something like SELECT * from (SELECT DISTINCT 'location' FROM myTable) or something like that, but it says I have a vague syntax error.

Is there a good way to grab the rest of each DISTINCT row and move it to a new table all in one go?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql