I have two mysql table , table event and table eventvenue.
I want to get other event from a venue.
--------------table event:---------------
id_e
id_event
title
content
-------------- table eventvenue:--------------
id_ev
id_event_ev
id_location_ev
I use join to get other event from a venue:
SELECT *
FROM eventvenue
JOIN event ON eventvenue.id_event_ev = event.id_event
WHERE eventvenue.id_location_ev=1
The result is:
id_ev id_event_ev id_location_ev id_e id_event title content ----- ----------- -------------- ---- -------- ------ ------------ 1 2 1 2 2 eventA aaaaaaaaaaaa 2 2 1 2 2 eventA aaaaaaaaaaaa 1 4 1 4 4 eventB bbbbbbbbb 1 9 1 9 9 eventC cccccccc 3 5 1 5 5 event5 555555
The output contains two rows with the same id_event_ev/id_event value of 2.
How can I show only distinct event IDs per location? Like this:
id_ev id_event_ev id_location_ev id_e id_event title content ----- ----------- -------------- ---- -------- ------ ------------ 1 2 1 2 2 eventA aaaaaaaaaaaa 1 4 1 4 4 eventB bbbbbbbbb 1 9 1 9 9 eventC cccccccc 3 5 1 5 5 event5 555555
Note: id_ev is not important.