E_Blue
E_Blue

Reputation: 1151

I need to join many query results in one result

I have many simple query to run in MySQL Workbench:

SELECT deviceID
     , from_unixtime(timestamp) 
  FROM EventData 
 where accountID = '001' 
   and deviceID = 'FFF'   
 order 
    by timestamp desc 
 limit 1;

I'm doing this to get the max timestamp value of every deviceID in a really huge active table that's why I make many queries to get faster results.

I tried with "deviceID IN(...)" but it takes too long and I don't want to hung up the server.

Upvotes: 0

Views: 34

Answers (1)

Caius Jard
Caius Jard

Reputation: 74605

Why aren't you using built in functions for summarising data?

SELECT 
  deviceID,
  from_unixtime(MAX(timestamp)) as timestamp
FROM 
  EventData 
where 
  accountID='001'
GROUP BY 
  deviceID

Upvotes: 1

Related Questions