SELECT model
FROM table_name AS t1
WHERE model = 1401
SELECT
t1.id,
CONCAT('[{',
GROUP_CONCAT(
(SELECT CONCAT('field1: ', t2.field1, ', field2: ' t2.field2) FROM t2 WHERE t2.id = t1.id)
SEPARATOR ' }, { '
), '}]'
FROM t1 GROUP BY t1.id
CREATE TRIGGER `add_message` BEFORE INSERT ON `messages` FOR EACH ROW BEGIN
UPDATE user SET sended = sended + 1 WHERE user_id = new.user_id_from;
UPDATE user SET received= received + 1 WHERE user_id = new.user_id_to;
END;