0

I have a database with thousands of entries

"id" is the primary key

"event_description"

"event_time"

"location"

In a php script i need to select all rows from the table and if "locationXXX" appears in more than one row collect the various values for "event_description" paired with respective "event_time" and echo them as list items

if instead there are no duplicates then select it normally and echo the results

Altering table structure is an option but i'd rather not

Any help is highly appreciated

1
  • What does "echo it normally" mean? Why not just make them a list of one element, so you can display singletons and duplicates the same way? Commented Nov 3, 2013 at 18:29

1 Answer 1

1

Assuming the table is called event

SELECT location, event_description, event_time
FROM event
GROUP BY location
HAVING COUNT(location) > 1;
Sign up to request clarification or add additional context in comments.

1 Comment

ps. It's preferred that if you ask a question on StackOverflow, you should attempt to come up with a solution yourself i.e. what have you tried?, before asking for one, but I knew what the answer was, so here it is :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.