By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE lights (
`Id` int,
`tpl2` VARCHAR(7),
`tpl3` VARCHAR(7),
`tpl4` VARCHAR(7),
`dateandtime` daTETIME
);
INSERT INTO lights
(`Id`, `tpl2`, `tpl3`, `tpl4`, `dateandtime`)
VALUES
('240', 'L13—OFF', 'L14—OFF', 'L15—ON', '2021-10-24 16:31:19'),
('239' ,'L13—OFF', 'L14—ON', 'L15—OFF', '2021-10-24 15:30:18'),
('238' ,'L13—ON', 'L14—OFF', 'L15—OFF', '2021-10-24 14:28:17'),
('237' ,'L13—OFF', 'L14—OFF', 'L15—OFF', '2021-10-24 16:27:16');
SELECT * FROM lights WHERE CONCAT_WS('', `tpl2`, `tpl3`, `tpl4`) LIKE '%—ON%'
Id | tpl2 | tpl3 | tpl4 | dateandtime |
---|---|---|---|---|
240 | L13—OFF | L14—OFF | L15—ON | 2021-10-24 16:31:19 |
239 | L13—OFF | L14—ON | L15—OFF | 2021-10-24 15:30:18 |
238 | L13—ON | L14—OFF | L15—OFF | 2021-10-24 14:28:17 |