Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Probably description and filename appears because these names exists on only one of the tables but <strong>title</strong> is on both tables.</p> <p>If you use the query:</p> <pre><code>SELECT * FROM promo JOIN items ON promo.id = items.promo_id WHERE promo.id='$promo_id'" </code></pre> <p>The names of the fields are need to be in the way <strong>table.field</strong> . it's very in useful to expecify the names of the fields you need to get to help you and to fetch only the data you need and not all the table. This makes the method faster to retrive the rows and prevent problems with the names.</p> <p>Also you can specify the name of a column wit the sentence "AS" Example:</p> <pre><code>SELECT promo.title AS title, promo.description AS description, items.filename AS filename FROM promo JOIN items ON promo.id = items.promo_id WHERE promo.id='$promo_id'" </code></pre> <p>And you get a table like (i setted imaginary data on it):</p> <pre><code>title | description | filename ------------------------------- title1|description1 | filename1 title1|description1 | filename2 title2|description2 | filename3 </code></pre> <p><em>Tips:</em></p> <ul> <li><p>If you got more than one item per promo all data is repeated on each row. </p> <ul> <li>You need to queries to display all items per promo without repeat the promo data,make more complex query or add some code.</li> </ul></li> <li><p>If you don't have any item for the promo the promo is does not appears into the list. </p> <ul> <li>You need to use list al promos and by each list its own items to show the promos without items or use an OUTER JOIN query. </li> </ul></li> </ul>
 

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