php - Combine 2 queries from different tables with different fields names -
i select , retrieve results 2 separate database tables , loop them within 1 html table. commands , name them separately, combine results , loop through them. there way of doing 1 query though?
the example below not work, logic behind i'd achieve.
$sql = "select * table3 column5 = 'yes'"; $data = mysql_query($sql); $sql = "select * table1 column1 = 'yes'"; $data = mysql_query($sql); // loops through records displaying in table format for($loop = 0; $loop < mysql_num_rows($data); $loop++) { $row = mysql_fetch_assoc($data); $ref = $row["ref"]; // rest of fields }
note: know mysql deprecated. moving on pdo when rebuild site need use mysql
function.
select * table3 join table1 on table3.column5=table1.column1 , table3.column5='yes'
or,change mysqli , use http://docs.php.net/mysqli.multi-query
Comments
Post a Comment