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

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -