mysql - pulling values from two tables after Select distinct id on another table -


Sensors are spreading around my house, they send all data to an MSLL DB. Sensors send several samples of communication per second with DB which is every 5 minutes.

I have general sensor information (primary key sensor)

on the table 'sensor' I need to draw the most recent sample time and table 'sensor' from the table 'censored' On the most recent last connection from the table 'SensorMoritoring' for each specific sensor ID. So I can compare them to PHP.

Right now I am doing this with the whiles in PHP but I think an easy and more efficient way to do this with SQL is to Page 21 questions are done)

I have this:

  Sensor ID selection from sensor   

and then within a short time:

  $ query1 = "Select IOS = Select Sensorizing by Selecting Selection". $ Line ["sensorID"] "order limit description description of the last contact"; $ Query2 = "Sensitendar where sensor id =" sample time from selection time ". $ Line ["sensorld"]. "Order of Samplit in Inability 1";   

Is there a way to do this with a single SQL query ? (Possibly with Johns?) Avoid long PHP code?

The end result will be something like this

  Sensor Last Connection Sample Time ------------------- ------ --------------------------- 01 2014-04-20 09:38:56 2014-04-20 09 : 30: 00 02 2014 -04-20 09:35:05 2014-04-19 10:15:00 03 2014-04-20 09:33:27 2014-04-20 09:26:00 04-04- 04 09:45: Just one additional explanation of my project: In this case I could see that there are problems in sensor 02 because the most recent samples are older than 15 minutes but DB; The sensor 04 is communicating, but not collecting all the samples.  

It is also said that: Sometimes sample time can be faucet.

You should be able to use all of these in a query:

  SELECT s.SensorId, MAX (m.LastConnection) AS LastConnection, MAX (D. Sampling Time) S S sample time from sensor SEE and IIS (MS-ENERIAID) on SXOIR = M SENSER IDEIDE except join (SSCIRID = D. censid) Group Sscrd;    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -