vendredi 9 janvier 2015

Create an UPDATE MySQL query based on already working SELECT one

I would like to create and UPDATE MySQL query based on a SELECT statement that is already working.


So I have the following select statement that joins two tables - tbl_random and tbl_products by finding a random record from the second table:



$sql_select = "SELECT tbl_random.keyword, tbl_random.model_id, tbl_random.series,
tbl_products.make, tbl_products.model

FROM tbl_random LEFT OUTER JOIN
tbl_vehicles
ON tbl_random.model_id = tbl_vehicles.model

GROUP BY tbl_random.keyword
ORDER BY RAND()";

$rs_select = $db -> Execute($sql_select);


What UPDATE query should I use in order to the able to update the make and model fields in tbl_random, with some respective random values from tbl_products?





Aucun commentaire:

Enregistrer un commentaire