SET @selected_tariff=2;
SELECT
CASE WHEN
(
(SELECT LENGTH(tariff_traffic_limit) FROM tariffs WHERE tariff_id=@selected_tariff)>0
)
THEN
(
CASE WHEN
(
LENGTH
(
INSERT INTO traffic_balance VALUES
(
(SELECT MAX(balance_id) FROM balances),
(SELECT tariff_traffic_limit FROM tariffs WHERE tariff_id=@selected_tariff)
)
) > 0
)
THEN
1
ELSE
0
END
)
END;
mysql ругается:
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 'INTO traffic_balance VALUES ( (SELECT MAX(balance_id) FROM balances), ' at line 12
вижу что беда в INSERT INTO, может его нельзя тут ставить вовсе? кто знает подскажите