joining tables

From: Eric @home (@home)
Date: Sun Oct 10 1999 - 09:50:22 EST


Next issue is I have six tables. Five of them hold two columns each, the
value and an ID number.
The sixth table is where I have all the infomation along with an ID
number from each of the five other tables. When I search the table and
want to display the output with a normal query it displays the values.
EX. 1, 1, 2, 4, 5, good, fred, whatever, next, etc.

I am trying to display the value of the fields from the other tables and
not the ID numbers.

table sport
sport_type, sport_id
Baseball, 1

So instead of a '1' I want the value 'Baseball' to show.

So far I have tried the following, what am I missing?

--------------------------------
This first example I was just trying to get sport_type from the sport
table to show.
And I get the following error message- Error: Reference to un-selected
table ""

$err = msqlQuery ($db, "select sport_card.item_id, sport_card.year_id,
sport_card.makers_id, sport_card.condition_id, sport_card.description,
sport_card.name, sport_card.qty, sport_card.cardnum, sport_card.price,
sport.sport_type from sport_card, sport where item_id = $id");
              if ($err < 0) {
                      printf ("Error: $ERRMSG\n");
                      exit (1);
              }
              else {
                      $res = msqlStoreResult ();
                      $row = msqlFetchRow ($res);
                      if (#$row > 0) { printf ("
<TR><TD>Item Number:<TD><B>%s</B>\n", $row[0]);
                              printf ("<TR><TD>Year:<TD><B>%s</B>\n",
$row[1]);
                              printf ("<TR><TD>Sport:<TD><B>%s</B>\n",
$row[2]);
                              printf ("<TR><TD>Maker:<TD><B>%s</B>\n",
$row[3]);
                              printf
("<TR><TD>Condition:<TD><B>%s</B>\n", $row[4]);
                              printf
("<TR><TD>Description:<TD><B>%s</B>\n", row[5]);
                              printf ("<TR><TD>Name:<TD><B>%s</B>\n",
$row[6]);
                              printf ("<TR><TD>Quanity:<TD><B>%s</B>\n",
$row[7]);
                              printf ("<TR><TD>Card
Number:<TD><B>%s</B>\n", row[8]);
                              printf ("<TR><TD>Price:<TD><B>%s</B>\n",
$row[9]);
                      }
                      else {
                              echo ("<TR><TD colspan=8>No matching
entries found.\n");
                      }
                      msqlFreeResult ($res);
              }
>
---------------------------------------------------------------

thanks,
eric

-------------------------------------------------------------------------
To unsubscribe, go to http://www.Hughes.com.au/extras/email/



This archive was generated by hypermail 2b30 : Mon Mar 04 2002 - 09:03:51 EST