php - SQL Join Returns null -
i trying return values database
what have
users
user_id (pk)

own_events
user_id (fk)
event_id(pk) 
attendees
user_id (fk)
event_id(fk)

what need return
i need return rows in attendees that's event_id equals value,status not equal 3 , , event_name value of event own_events table , email value users table
what have tried have been trying sort of combinations couldnt figure out doing wrong http://www.codeproject.com/articles/33052/visual-representation-of-sql-joins
even returns null:
$query ="select a1.event_name,a1.start_date attendees a1 inner join own_events a2 on a2.event_id = a1.event_id a1.event_id = $event_id"; or
$query ="select a1.event_name,a1.start_date ,a3.email attendees a1 inner join own_events a2 on a2.event_id = a1.event_id inner join users a3 on a3.user_id = a1.user_id a1.event_id = $event_id , a1.status != 3"; what query call need make?
edit::::: sample data:
attendees

ownevents

users

the problem join users table. joining attendees. however, think want owner email.
this switches joins left outer join. return matching rows in attendees table, when there no matches in other tables:
select oe.event_name, a.start_date, u.email attendees left outer join own_events oe on oe.event_id = a.event_id left outer join users u on a.user_id = u.user_id a.event_id = $event_id , a.status <> 3
Comments
Post a Comment