I am using mysql & perl. I have the following values for one of my columns in my database:
123 Hollywood
345 New York
847 Hollywood
192 Boston
876 Chicago
I want to select all of the distinct cities….ie, the results would be:
Hollywood
New York
Boston
Chicago
Is there a way to do this via msyql? I would imagine some sort of REGEXP but can’t seem to get the logic:
SELECT * FROM table WHERE address REGEXP ''
Assuming that your address is always in the format
<numbers><space><city>Here’s the test data I used to verify the query works. Note that I named the test table
locations. My MySQL server is version 5.1.36:Here’s the exact query I ran on that table:
Here’s the result I got: