tanisha s tanisha s - 7 months ago 30
HTML Question

Joining 3 tables with separate where clauses

i have 3 tables:

USERS(id, username, email, password)

QUESTIONS(id, uid, type, ques, date, time)

ANSWERS(id, a_uid, qid, reply, a_date, a_time)

i want to select * from all three tables

where $_SESSION[‘id’] = questions.uid

& users.id = questions.uid

& questions.id = answers.qid

how can i achieve this?

 select * 
 from USERS
 inner join QUESTIONS  on users.id = questions.userid
 inner join ANSWERS on questions.id = answers.qid
 where  questions.uid = $_SESSION['id'] ;