SQL Subquery with two selects from different table is giving random selection
select top(1) Questions.Ques_ID, Question
from Questions
where Questions.Ques_ID in(
select top(4) Answers.Que_ID,Answer
from Answers
where Questions.Ques_ID = Answers.Que_ID
order by newid())
When using IN()
, same amount(and type) of elements should appear on both sides!
select top(1) Questions.Ques_ID, Question
from Questions
where Questions.Ques_ID in(
select top(4) Answers.Que_ID
from Answers
where Questions.Ques_ID = Answers.Que_ID
order by newid())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With