Topic: Insertion in the table under a condition in mysql...
All greetings. Let we have some table
CREATE TABLE t1 (id INT, free_places INT, PRIMARY KEY (id));
And here it would be desirable for me to add in the second table
CREATE TABLE t2 (id INT, fname VARCHAR (30), lname VARCHAR (30), bday DATE...);
Values, BUT ONLY under a condition if value of a certain field free_places in t1 we tell> 30. Well here for example
If (SELECT free_places FROM t1 WHERE id = 1)> 30,
INSERT INTO t2 VALUES (...)
It would be quite good to throw still an error any with the text of an error otherwise.
Such generally it is possible to implement? I am simple something all rummaged around already. Googled already and separately INSERT INTO and INSERT INTO else if and so on.