What is wrong with the syntax or query?
SET @q=1000;
SET @p=5.00;
SELECT @ccount := COUNT(*) FROM 1detail WHERE price>=@p;
if(@ccount='0') THEN
INSERT INTO 1detail (price,quantity) VALUES (@p,@q);
ELSE
INSERT INTO 2detail (price,quantity) VALUES (@p,@q);
END IF;
It gives me the error:
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 'if(@ccount='0') THEN INSERT INTO 1detail (price,quantity) VALUES (@p,@q)' at line 1:
To create table (that is working):
CREATE TABLE 1detail
(
quantity int,
price DECIMAL(15,2)
);
CREATE TABLE 2detail
(
quantity int,
price DECIMAL(15,2)
);
INSERT INTO 1detail
(quantity, price)
VALUES
('5', '10');