<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[problema inner join]]></title><description><![CDATA[<p dir="auto">Ciao a tutti, sto costruendo un cms per il mio portale di hotel e ho riscontrato un errore nel unire 2 tabelle con la funzione inner join, mi duplica i risultati di un  "hotel" per quante offerte sono ad esso associate<br />
le due tabelle sono cosi' composte:<br />
la tabella "hotel" ha questi campi: idhotel,tipologia,nome,email,tel,stato</p>
<p dir="auto">invece la tabella "offerte" e' composta cosi':<br />
idofferte,prezzo,dal,al,idhotel</p>
<p dir="auto">la pagina dei risultati è questa:</p>
<pre><code class="language-php">&lt;link href="ischia_hotel.css" rel="stylesheet" type="text/css"&gt;
&lt;?
require_once ('conn.php');

$query = 'SELECT * FROM hotel INNER JOIN offerte ON hotel.idhotel=offerte.idhotel';
$result=mysql_query($query);

while ($row=mysql_fetch_array($result)) :
?&gt;
&lt;div align="center"&gt;&lt;br /&gt;
  &lt;table class="ischia_box_interno" width="500" border="0" cellspacing="0" cellpadding="0"&gt;
    &lt;tr&gt;
    &lt;td&gt;&lt;div align="center"&gt;&lt;? echo' ' . $row['nome'] . ' ';?&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;div align="center"&gt;&lt;? echo' ' . $row['prezzo'] . ' ';?&gt; EURO&lt;/div&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
   &lt;br /&gt;
   &lt;?
                endwhile;
               @mysql_close();
                ?&gt;
   &lt;br /&gt;
  &lt;br /&gt;
&lt;/div&gt;
</code></pre>
<p dir="auto">Grazie</p>
]]></description><link>https://dev.connect.gt/topic/151799/problema-inner-join</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 20:26:49 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/151799.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 May 2011 17:30:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to problema inner join on Sat, 21 May 2011 13:27:34 GMT]]></title><description><![CDATA[<p dir="auto">Grazie per la risposta ma, niente da fare, continua a non unirmi i risultati sarà perchè sia nella tabella hotel che nella tabella offerte ho la stessa riga chaiamata idhotel?<br />
grazie</p>
]]></description><link>https://dev.connect.gt/post/1005608</link><guid isPermaLink="true">https://dev.connect.gt/post/1005608</guid><dc:creator><![CDATA[princo]]></dc:creator><pubDate>Sat, 21 May 2011 13:27:34 GMT</pubDate></item><item><title><![CDATA[Reply to problema inner join on Fri, 20 May 2011 11:30:27 GMT]]></title><description><![CDATA[<p dir="auto">Fai attenzione alle maiuscole e alla punteggiatura nei tuoi messaggi...<br />
Per quanto riguarda il problema puoi usare GROUP BY per raggruppare.</p>
]]></description><link>https://dev.connect.gt/post/1005613</link><guid isPermaLink="true">https://dev.connect.gt/post/1005613</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Fri, 20 May 2011 11:30:27 GMT</pubDate></item><item><title><![CDATA[Reply to problema inner join on Fri, 20 May 2011 10:08:21 GMT]]></title><description><![CDATA[<p dir="auto">Grazie per la risposta, ma non ce' un modo per far si che le determinate offerte associate all'id dell hotel escono ragruppate invece di duplicare  sempre lo stesso hotel?<br />
Grazie<br />
Edit:<br />
Ho scritto cosi' il codice, adesso invece di duplicarmi gli hotel mi mette tutte le offerte presenti nel database per ogni hotel presente mammamia che casino!! <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--disappointed" style="height:1.4em;width:auto;vertical-align:middle" title=":(" alt="😞" /></p>
<pre><code class="language-php">&lt;?
require_once ('conn.php');

$query = 'SELECT * FROM hotel WHERE stato="aperto" ORDER by idhotel ASC';
$result=mysql_query($query);

while ($row=mysql_fetch_array($result)) :
?&gt;
                  &lt;br&gt;
                  &lt;table align="center" class="ischia_box" border="0" cellpadding="0" cellspacing="0" width="520"&gt;
                    &lt;tbody&gt;
                      &lt;tr align="center"&gt;
                        &lt;td height="60" width="90" class="tipologia"&gt;&lt;div align="center"&gt;&lt;? echo '&lt;h2&gt;  '  . $row['tipologia'] . '  &lt;/h2&gt;';?&gt;&lt;/div&gt;&lt;/td&gt;
                        &lt;td width="452" height="60" align="left"&gt;&lt;div align="left"&gt;&lt;? echo '&lt;h2&gt;&lt;a class="b" href="hotel_ischia.php?id=' . $row['idhotel'] .
            '"&gt;' . $row['nome'] .'&lt;/h2&gt;&lt;/a&gt;&lt;/th&gt;'; ?&gt;&lt;/div&gt;                          &lt;/td&gt;
                      &lt;/tr&gt;
                    &lt;/tbody&gt;
                  &lt;/table&gt;
                  &lt;table align="center" class="ischia_box_nolinea" border="0" cellpadding="0" cellspacing="0" width="520"&gt;
                    &lt;tbody&gt;
                      &lt;tr valign="top"&gt;
                        &lt;td height="506"&gt;                          &lt;div class="ischia_txt4" align="center"&gt;
                            &lt;p&gt;&amp;nbsp;&lt;/p&gt;
                            &lt;table border="0" cellpadding="0" cellspacing="0" width="500"&gt;
                              &lt;tbody&gt;
                                &lt;tr valign="top"&gt;
                                  &lt;td align="left" class="descrizione-hotel" height="143" width="280"&gt;&lt;? echo ' ' . $row['descr_breve'] . ' ';?&gt;&lt;/td&gt;
                                  &lt;td width="220"&gt;&lt;div align="center"&gt;&lt;br&gt;
                                          &lt;? echo ' ' . $row['dal'] . ' ';?&gt;&lt;/div&gt;&lt;/td&gt;
                                &lt;/tr&gt;
                              &lt;/tbody&gt;
                            &lt;/table&gt;&lt;br&gt;
                            &lt;br&gt;
                            &lt;strong class="ischia_supplementi_2"&gt;&lt;/strong&gt;&lt;? require_once ('conn.php');
                            $query2 = 'SELECT * FROM hotel INNER JOIN offerte ON hotel.idhotel=offerte.idhotel';
$result2=mysql_query($query2);

while ($row=mysql_fetch_array($result2)) :
?&gt;&lt;br&gt;
                            &lt;table class="ischia_box_interno" border="0" cellpadding="0" cellspacing="0" width="500"&gt;
                              &lt;tbody&gt;
                                &lt;tr&gt;
                                  &lt;td bgcolor="#59770e"&gt;
                                    &lt;div class="ischia_testo" align="center"&gt;&lt;strong&gt;&lt;? echo ' ' . $row['nome_offerta'] . ' ';?&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
                                &lt;/tr&gt;
                                &lt;tr valign="top"&gt;
                                  &lt;td height="178" width="500"&gt; &lt;br&gt;
                                      &lt;div align="center"&gt;
                                        &lt;table border="0" cellpadding="0" cellspacing="0" width="440"&gt;
                                          &lt;tbody&gt;
                                            &lt;tr&gt;
                                              &lt;td&gt;
                                                &lt;div align="center"&gt;&lt;span class="data_hotel"&gt;&lt;strong&gt;Dal &lt;? echo ' ' . $row['dal'] . ' ';?&gt; Al &lt;? echo ' ' . $row['al'] . ' ';?&gt; &lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;
                                            &lt;/tr&gt;
                                            &lt;tr&gt;
                                              &lt;td&gt;
                                                &lt;div align="center"&gt;&lt;span class="ischia-euro"&gt;&lt;strong&gt;&lt;? echo ' ' . $row['prezzo'] . ' ';?&gt; EURO&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;
                                                    &lt;span class="ischia_txt1"&gt;&lt;strong&gt;AL GIORNO PER &lt;/strong&gt;&lt;/span&gt;&lt;span class="ischia_txt2"&gt;&lt;strong&gt; PERSONA &lt;/strong&gt;&lt;/span&gt;&lt;span class="ischia_txt1"&gt;&lt;strong&gt;IN &lt;? echo ' ' . $row['trattamento'] . ' ';?&gt;&lt;br&gt;
                                                    &lt;br&gt;
                                                &lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;
                                            &lt;/tr&gt;
                                          &lt;/tbody&gt;
                                        &lt;/table&gt;
                                        &lt;br&gt;
                                        &lt;p&gt; &lt;span class="descrizione-hotel"&gt; &lt;strong class="ischia_txt3"&gt;INCLUSO NEL PREZZO:&lt;/strong&gt; &lt;? echo ' ' . $row['incluso'] . ' ';?&gt;&lt;/span&gt;&lt;/p&gt;
                                        &lt;p&gt;&amp;nbsp;&lt;/p&gt;
                                    &lt;/div&gt;&lt;/td&gt;
                                &lt;/tr&gt;
                              &lt;/tbody&gt;
                            &lt;/table
&gt;
                            &lt;?
                endwhile;
               mysql_close($query);
                ?&gt;
                            &lt;br&gt;
                            &lt;br&gt;
                            &lt;table border="0" cellpadding="0" cellspacing="0" width="500"&gt;
                              &lt;tbody&gt;
                                &lt;tr&gt;
                                  &lt;td width="25"&gt;&lt;div align="center"&gt;&lt;img src="ischia_images/ischia_hotel_mail_blu.jpg" alt="ischia prenotazioni" height="11" width="17"&gt;&lt;/div&gt;&lt;/td&gt;
                                  &lt;td class="menu" width="278"&gt;&lt;a href="mailto:info@ischiatravelnet.com" class="c"&gt;&lt;? echo ' ' . $row['email'] . ' ';?&gt;&lt;/a&gt;&lt;/td&gt;
                                  &lt;td width="197"&gt;&lt;div class="ischia-offerte" align="center"&gt;&lt;strong&gt;&lt;img src="ischia_images/schia-telefono.gif" height="13" width="20"&gt; &lt;/strong&gt;&lt;strong class="ischia-offerte"&gt;&lt;? echo ' ' . $row['tel'] . ' ';?&gt;&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
                                &lt;/tr&gt;
                              &lt;/tbody&gt;
                            &lt;/table&gt;
                            &lt;p&gt;&amp;nbsp;&lt;/p&gt;
                          &lt;/div&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                    &lt;/tbody&gt;
                  &lt;/table&gt;
                  &lt;br&gt;
                  &lt;br&gt;
                  &lt;span class="ischia_txt4"&gt;
                  &lt;?
                endwhile;
               mysql_close($query2);
                ?&gt;
                  &lt;/span&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt; &lt;/tr&gt;
              &lt;tr&gt; &lt;/tr&gt;
            &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;&lt;/td&gt;
                  &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;              
&lt;div align="center"&gt;&lt;/div&gt;
  &lt;div align="center"&gt;
    &lt;table class="ischia_boxsotto" border="0" cellpadding="0" cellspacing="0" width="740"&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          fo@ischiatravelnet.com" class="ischia_vedisito"&gt;info@ischiatravelnet.com&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;br&gt;
    &lt;br&gt;
    
&lt;/div&gt;
&lt;/body&gt;&lt;/html&gt;
</code></pre>
<p dir="auto">Se vuoi vedere l'esempio scrivi il link del sito in firma aggiungendo    /prova/<br />
Grazie.</p>
]]></description><link>https://dev.connect.gt/post/1005609</link><guid isPermaLink="true">https://dev.connect.gt/post/1005609</guid><dc:creator><![CDATA[princo]]></dc:creator><pubDate>Fri, 20 May 2011 10:08:21 GMT</pubDate></item><item><title><![CDATA[Reply to problema inner join on Thu, 19 May 2011 07:07:13 GMT]]></title><description><![CDATA[<p dir="auto">Ciao princo,<br />
la query mi sembra corretta, è normale che se un hotel ha 2 offerte esce volte.</p>
]]></description><link>https://dev.connect.gt/post/1005612</link><guid isPermaLink="true">https://dev.connect.gt/post/1005612</guid><dc:creator><![CDATA[thedarkita]]></dc:creator><pubDate>Thu, 19 May 2011 07:07:13 GMT</pubDate></item></channel></rss>