luca
luca

Reputation: 37136

mysql query result

I have built this query that is kind of self explanatory:

SELECT events.*,(SELECT COUNT(*) 
FROM events_participants 
WHERE events_participants.eventid=events.eventid)AS participants,linkViews.totViews 
FROM events INNER JOIN linkViews ON events.event_id=LinkViews.eventid

In the events table i have 6 events but this query return just 3 of them (ID:1,2,4).

enter image description here

Where is this query wrong?

Upvotes: 0

Views: 85

Answers (1)

Arun
Arun

Reputation: 3077

Try a LEFT OUTER JOIN instead of INNER JOIN. Probably there is no matching eventid in the LinkViews table/view.

Upvotes: 1

Related Questions