select from table only if the id exist in that table mysql pdo php -
i want create select query using join on 3 or more tables. have 3 tables namely t1
, t2
, t3
, common column id
existing in 3 tables. want select 3 table if id exists in table query this.
select * t1 inner join t2 on t1.id = t2.id inner join t3 on t2.id = t3.id t1.id = 1 , t2.id = 1 , t3.id = 1
the query returning values if id exists in 3 tables. if not in table example t3 not return anything. looking way if not exist in t3
should proceed select t1
, t2
is need?
select * t1 inner join t2 on t1.id = t2.id left join t3 on t2.id = t3.id t1.id = 1 , t2.id = 1 , (t3.id = null or t3.id = 1)
Comments
Post a Comment