-1
SELECT * 
						FROM question 
						LEFT JOIN answer ON question.Que_ID=answer.Que_ID 
						AND question.Que_Answer1=answer.Ans_Answer1 
						AND question.Que_Answer2=answer.Ans_Answer2 
						AND question.Que_Answer3=answer.Ans_Answer3
						AND question.Que_Answer4=answer.Ans_Answer4
						
						AND question.Tes_ID=7
AND answer.Use_ID=1

This should only show record that are use_ID=1 and Tes_ID =7. But in MySQL, there are data for test ID=8 and etc. isnt it only suppose to be 7.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by xxreenaxx1
0

The code you have is selecting every record from question and only joining info from records in answer that match the criteria. I think what you ar looking for would be:

SELECT * 
FROM question 
LEFT JOIN answer ON question.Que_ID=answer.Que_ID 
AND question.Que_Answer1=answer.Ans_Answer1 
AND question.Que_Answer2=answer.Ans_Answer2 
AND question.Que_Answer3=answer.Ans_Answer3
AND question.Que_Answer4=answer.Ans_Answer4
WHERE				
question.Tes_ID=7
AND answer.Use_ID=1
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.