Reputation: 45
Is it possible to do the following in MYSQL without a stored procedure:
SET @q='10';
SET @p='5';
SELECT @a_rows := COUNT(*) FROM 'main1' WHERE status='0' && price<= @p && quantity > '0';
IF @a_rows = '0' THEN
INSERT INTO detail1 (quantity,price,status) VALUES (@q,@p,'0');
INSERT INTO detail2 (quantity,price,status) VALUES (@q,@p,'0');
ELSEIF @a_rows='1' THEN
INSERT INTO detail3 (quantity,price,status) VALUES (@q,@p,'0');
ELSE
;
ENDIF
It always returns error #1064
Upvotes: 0
Views: 31
Reputation: 204746
No, that is not possible.
You need a shell around these instructions like a procedure, trigger or function. Only a single query can run alone in MySQL.
Upvotes: 1