All pastes #246165 Raw Edit

Anonymous

public text v1 · immutable
#246165 ·published 2006-11-11 23:05 UTC
rendered paste body
"Simplified", DOESN'T work:
_________________________

SELECT responses.id, responses.category, answers0.description AS 29radio, answers1.description AS col88, answers2.description AS col89, answers3.description AS 32radio
FROM responses, options
LEFT JOIN answers AS answers0 ON responses.id = answers0.response
AND answers0.option_id = options.id
AND options.question = answers0.question
AND options.question =29
LEFT JOIN answers AS answers1 ON responses.id = answers1.response
AND answers1.option_id = "88"
LEFT JOIN answers AS answers2 ON responses.id = answers2.response
AND answers2.option_id = "89"
LEFT JOIN answers AS answers3 ON responses.id = answers3.response
AND (
answers3.option_id = "97"
OR answers3.option_id = "98"
OR answers3.option_id = "99"
)
WHERE responses.inquiry =16
LIMIT 0 , 30




Works:
_________________________

SELECT responses.id, responses.category, answers0.description AS 29radio, answers1.description AS col88, answers2.description AS col89, answers3.description AS 32radio
FROM responses
LEFT JOIN answers AS answers0 ON responses.id = answers0.response
AND (
answers0.option_id = "90"
OR answers0.option_id = "91"
)
LEFT JOIN answers AS answers1 ON responses.id = answers1.response
AND answers1.option_id = "88"
LEFT JOIN answers AS answers2 ON responses.id = answers2.response
AND answers2.option_id = "89"
LEFT JOIN answers AS answers3 ON responses.id = answers3.response
AND (
answers3.option_id = "97"
OR answers3.option_id = "98"
OR answers3.option_id = "99"
)
WHERE responses.inquiry =16