Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your database schema is not completely clear to me, but it seems you can link tourists from the <strong>Tourist</strong> table to their extra charges in the <strong>EXTRA_CHARGES</strong> table via the <strong>Tourist_Extra_Charges</strong> table like this:</p> <pre><code>SELECT T.Tourist_ID ,T.Tourist_Name ,EC.Extra_Charge_ID ,EC.Extra_Charge_Description FROM Tourist AS T INNER JOIN Tourist_Extra_Charges AS TEC ON T.Tourist_ID= TEC.Tourist_ID INNER JOIN EXTRA_CHARGES AS EC ON TEC.Extra_Charge_ID = EC.Extra_Charge_ID; </code></pre> <p><strong>EDIT</strong></p> <p>If you want to be able to filter on <i>Reservation_ID</i>, you'll have to join the tables <strong>Tourist_Reservations</strong> and <strong>Reservations</strong> as well, like this:</p> <pre><code>SELECT T.Tourist_ID ,T.Tourist_Name ,EC.Extra_Charge_ID ,EC.Extra_Charge_Description FROM Tourist AS T INNER JOIN Tourist_Extra_Charges AS TEC ON T.Tourist_ID= TEC.Tourist_ID INNER JOIN EXTRA_CHARGES AS EC ON TEC.Extra_Charge_ID = EC.Extra_Charge_ID INNER JOIN Tourist_Reservations AS TR ON T.Tourist_ID = TR.Tourist_ID INNER JOIN Reservations AS R ON TR.Reservation_ID = R.Reservation_ID WHERE R.Reservation_ID = 27; </code></pre> <p>As for your database schema: please note that the field <i>Extra_Charge_ID</i> is not necessary in your <strong>Tourist</strong> table: you already link tourists to extra charges via the <strong>Tourist_Extra_Charges</strong> table. It can be dangerous to the sanity of your data to make these kind of double connections.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload