MySQL Forums
Forum List  »  German

Re: Benötige Hilfe bei Erstellung einer Query
Posted by: Peter Brawley
Date: November 16, 2020 12:46PM

Ist es das was du meinst?

drop table if exists tbl;
create table tbl(
  timestamp timestamp,
  device varchar(32),
  type varchar(8),
  event varchar(64),
  reading varchar(32),
  value decimal(8,4),
  unit varchar(8)
);
insert into tbl values
('2020-11-13 19:26:02', 'DatabaseLog', 'DBLOG', 'CacheUsage: 2'                     , 'CacheUsage'                , 2     , ''),
('2020-11-13 19:26:02', 'DatabaseLog', 'DBLOG', 'background_processing_time: 0.0152', 'background_processing_time', 0.0152, ''),
('2020-11-13 19:26:02', 'DatabaseLog', 'DBLOG', 'sql_processing_time: 0.0042'       , 'sql_processing_time'       , 0.0042, ''),
('2020-11-13 19:26:02', 'DbLog'      , 'DBLOG', 'CacheUsage: 145'                   , 'CacheUsage'                , 145   , '');

-- DELETE
delete a 
from tbl a
join tbl b using(timestamp,reading)
where a.device='DatabaseLog' and b.device='DbLog';

select * from tbl;
+---------------------+-------------+-------+------------------------------------+----------------------------+----------+------+
| timestamp           | device      | type  | event                              | reading                    | value    | unit |
+---------------------+-------------+-------+------------------------------------+----------------------------+----------+------+
| 2020-11-13 19:26:02 | DatabaseLog | DBLOG | background_processing_time: 0.0152 | background_processing_time |   0.0152 |      |
| 2020-11-13 19:26:02 | DatabaseLog | DBLOG | sql_processing_time: 0.0042        | sql_processing_time        |   0.0042 |      |
| 2020-11-13 19:26:02 | DbLog       | DBLOG | CacheUsage: 145                    | CacheUsage                 | 145.0000 |      |
+---------------------+-------------+-------+------------------------------------+----------------------------+----------+------+

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Benötige Hilfe bei Erstellung einer Query
49
November 16, 2020 12:46PM


Sorry, only registered users may post in this forum.

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.