|
|
|
|
Bonjour, j'ai deux tables qui sont liés par un champ et j'essaye de faire une jointure ; j'ai bien essayé de la réaliser avec les exemples donné mais je n'y arrive pas.
-----------
Les tables :
annuairelinks_categories // champs (cid, title, cdescription).
annuairelinks_links // champs (lid, cid, ...).
-----------
J'essaye de joindre le champ 'cid' mais en affichant le 'title' de la première table et le 'count' (total des entrées) de la deuxième table.
-----------
La 1ère table affiche le nom des 'régions de france' et la deuxième table les adresse pour chaque région.
-----------
Je vous met un exemple de ma façon de faire mais qui ne fonctionne pas :
$result=mysql_query("SELECT title.annuairelinks_categories, count.annuairelinks_links, cid.annuairelinks_categories, cid.annuairelinks_links FROM annuairelinks_categories, annuairelinks_links WHERE annuairelinks_categories.cid = annuairelinks_links.cid");
while (list($title, $count) = mysql_fetch_row($result)) {
$rowcolor=tablos();
echo "<tr $rowcolor><td> $title</td><td align='center'>$count</td></TR>";
}
Salut
SELECT c.title, c.cid, count( l.lid ) FROM annuairelinks_categories AS c, annuairelinks_links AS l WHERE c.cid = l.cid GROUB BY c.cid Pour plus d'explications : jointure et AS : http://www.commentcamarche.net/sql/sqljoint.php3 Group by : http://www.commentcamarche.net/sql/sqltri.php3 A+, crabs ..., I think Slackware sounds better than 'Microsoft,' -- Patrick Volkerding - founder and maintainer of Slackware |