Double MySql query?

"UPDATE `trading` SET `flag`='1', `price_end`='$price' WHERE `time_end` <= '$time' AND `flag`='0'"

The question is, is it possible to make the query to update the table users if
1. `price_end` > `price_start` AND `line` = 'up'
2. `price_end` < `price_start` AND `line` = 'down'
And depending on this to update the user's balance. But I would like once in a single request.
June 10th 19 at 15:33
3 answers
June 10th 19 at 15:35
better make some and wrap it in a transaction
Yes, a good option, but still need a single query. Here is the requirement. - Myrtice commented on June 10th 19 at 15:38
, not a single query to update two tables - Sonny.Skiles commented on June 10th 19 at 15:41
Not something mean. Write more precisely later. - Myrtice commented on June 10th 19 at 15:44
June 10th 19 at 15:37
Thanks, I'll try. - Myrtice commented on June 10th 19 at 15:40
June 10th 19 at 15:39
CREATE TRIGGER `update_balance` AFTER UPDATE ON `trading`
FOR EACH ROW BEGIN
 IF (NEW.`line` = 'up' AND NEW.`price_end` > NEW.`price`) THEN
BEGIN
 UPDATE `clients` SET `balance` = `balance` + NEW.`sum` * 1.85 WHERE `email` = NEW.`user_id`;
END
 ELSE IF (NEW.`line` = 'down' AND NEW.`price_end` < NEW.`price`) THEN
BEGIN
 UPDATE `clients` SET `balance` = `balance` + NEW.`sum` * 1.85 WHERE `email` = NEW.`user_id`;
END
END
END;


Gives an error, what could be wrong?
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near " at line 5

5 string, this is the first UPDATE

Find more questions by tags MySQLSQL