tanisha s tanisha s - 1 year ago 68
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?

Answer Source
 select * 
 from USERS
 inner join QUESTIONS  on users.id = questions.userid
 inner join ANSWERS on questions.id = answers.qid
 where  questions.uid = $_SESSION['id'] ;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download