MySQL Forums
Forum List  »  MySQL Query Browser

Help for a query
Posted by: Luca V
Date: February 08, 2013 04:15AM

Hi, i need some help for a query.

This query works:

SELECT idcustomer,idpark,iddevice,date(datetime)
FROM `general inputs data` gid
where gid.`LAST UPDATE` >
(SELECT max(`LAST UPDATE`) FROM general_inputs_data_limited )
group by idcustomer,idpark,iddevice,date(datetime)

Takes from "general_inputs_data_limited" the max value of LAST UPDATE
and select all the value of another table "general_inputs_data" that have LAST UPDATE > of that value.

Now, i would delete these selected values from the first table "general_inputs_data_limited "

I tried this but doesn't work...

delete from general_inputs_data_limited
where idcustomer,idpark,iddevice,date(datetime)
IN
(
SELECT idcustomer,idpark,iddevice,date(datetime)
FROM `general inputs data` gid
where gid.`LAST UPDATE` >
(SELECT DATE_ADD(max(`LAST UPDATE`),INTERVAL -30 MINUTE) FROM general_inputs_data_limited)
group by idcustomer,idpark,iddevice,date(datetime)
)

The 2 table have the same field:
IDCUSTOMER, IDPARK, DATETIME -> PRIMARY KEY
IDDEVICE -> PRIMARY KEY but not used
LAST UPDATE -> FIELD

Any advise ?

Options: ReplyQuote


Subject
Written By
Posted
Help for a query
February 08, 2013 04:15AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.