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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -