php - Select SQL query from two different tables but same database -
i select sql query 2 different tables. both tables in same database.
this sql code , "air, temp, humidity, mq2" 1 table known "pi_sensors_network" while "dust" table known "pi_dust_sensor". may know how go selecting air, temp, humidity, mq2, dust 2 different tables same database? thanks!
on side note, there no relation between both tables. want fetch data 2 different tables.
$sql = "select air, temp, humidity, mq2, dust pi_sensors_network order time desc limit 1"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row
just use alias each table:
select t1.air, t1.temp, t1.humidity, t1.mq2, t1.dust dust1, t2.dust dust2 pi_sensors_network t1, pi_dust_sensor t2 order time desc limit 1";
Comments
Post a Comment