Search code examples
sqljoininner-join

Selecting data from 3 linked tables


I have three table review_form_languages, review_form_translations and rate_params.

  1. rate_params -> id, label

  2. review_form_languages -> id, name

  3. review_form_translations -> id, rate_params_id, review_form_languages_id, text

On table rate_params, I would like to get the associated review_form_translations.text linked by rate_params_id for that specific review_form_languages_id.

Would anyone kindly assist?


Solution

  • You seem to be looking for a simple JOIN. AFAIK, only two tables are involved :

    SELECT rp.*, rft.text
    FROM rate_params rp
    INNER JOIN review_form_translations rft ON rft.rate_params_id = rp.id
    WHERE rft.review_form_languages_id = ?
    

    You may replace the ? with the language id whose text you want to retrieve.