0

単一のテーブルの場合、通常は次のようにします。

$length = 42;
$result = mysql_query ('SELECT * FROM table WHERE length = "' . $length . '"', $dbconn);
$rowsfound = mysql_num_rows ($result);
if ($rowsfound == 1) {
    $row = mysql_fetch_array ($result);
    $tableid = $row ['table_id'];
    $tablecloth = $row ['tablecloth'];
    $height = $row ['height'];
    ...

しかし、次のように結合されたテーブルから行を取得する方法:

$chairid = 123;
$result = mysql_query ('SELECT * FROM table,chair WHERE chair.id = "' . $chairid . '" AND table.table_id = chair.table_id', $dbconn);
$rowsfound = mysql_num_rows ($result);
if ($rowsfound == 1) {
    $row = mysql_fetch_array ($result);
    $tableid = $row ['table.table_id'];
    $tablecloth = $row ['table.tablecloth'];
    $height = $row ['table.height'];
    ...

これは $table.tablecloth に値を返しません。私は何を間違っていますか?

4

4 に答える 4