我必须生成一个SQL查询来获取带有和不带匹配值的多个表数据并显示结果。我用过Left Join。但是,它没有显示所有值。
我的结果需要获得所有产品的所有问题和相应的答案,并且还建议我,数据库表设计中是否有任何缺陷?谢谢你的帮助。
SQL
SELECT
product.product_name AS 'Product',
question.question_id AS 'Id',
question.question_name AS 'Question',
answer.answer_value AS 'Answer'
FROM
question
LEFT JOIN
answer ON question.question_id = answer.question_id
LEFT JOIN
assessment ON answer.assessment_id = assessment.assessment_id
LEFT JOIN
product ON product.product_id = assessment.product_id
ORDER BY question.question_id
以上SQL只生成了答案而不是所有问题的问题