Fields from multiple tables & fetch-array - how?

From: Date: Mon, 23 Oct 2000 20:02:45 +0000
Subject: Fields from multiple tables & fetch-array - how?
Groups: php.windows 
Request: Send a blank email to php-windows+get-3455@lists.php.net to get a copy of this message
Hi I'm wanting to retrieve data from multiple tables that each have a field called NAME. Is this possible using the MYSQL_FETCH_ARRAY function ? eg: $query = "SELECT products.name, products.description, categories.name, subcategories.name " . "FROM products, categories, subcategories" ; $results = SQL_Update($query); // run the query while ( $row = mysql_fetch_array($results)): $name = $row["name"]; <-------- WHICH NAME will be returned? $description = $row["description"]; endwhile; Is it possible to use this syntax, possibly using something like $prod_name = $row["products.name"]? I really DON'T want to have to list out all the fields I want retrieved and then use: $prod_name = $row[0]; $cat_name = $row[2]; $subcat_name = $row[3]; as there are around twenty fields and I'd rather not have to count them all explicitly - too easy to miscount :-) Maybe I could put the three name fields first and use $row[0] syntax for these, and $row["description"] style for the rest ... Any thoughts Thanks Giovanni ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Giovanni Moretti * FAST PIC 16F84, Atmel 2051 & AVR development on SimmStick Palmerston North * Fringe Science, Brainwave Synchronisation, Remote Viewing New Zealand * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~ ZL2BOI ~~~~~* Visit Reflection Technology ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Giovanni Moretti * FAST PIC 16F84, Atmel 2051 & AVR development on SimmStick Palmerston North * Fringe Science, Brainwave Synchronisation, Remote Viewing New Zealand * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~ ZL2BOI ~~~~~* Visit Reflection Technology

« previous php.windows (#3455) next »