I am trying to query 4 tables(it works well when I query first 3 tables) and my table structure looks like,
1 Table - category
catid catname
1 AAA
2 BBB
2 Table - questions
quid qtype
1 data
2
3 data
3 Table - answers
ansid quid catid userid answer
1 1 1 1 test1
2 2 1 1 test2
3 3 2 1 test3
4 Table - concerns
concern_id catid userid ansid
1 1 1 1
2 1 4 3
Now my query is(with 3 tables)
SELECT category.catname,questions.quid,answers.catid,answers.ansid,answers.answer
FROM questions , answers ,category
where questions.qtype = 'data'
and questions.quid = answers.quid
and category.catid = answers.catid
and answers.userid = 1
And it gives me(which is fine)
catname quid catid ansid answer
AAA 1 1 1 test1
BBB 3 2 3 test3
Now I want to include the 4th table in the query and the resultant should look like
concern_id catname quid catid ansid answer
1 AAA 1 1 1 test1
null BBB 3 2 3 test3
And here I am stuck with the query.