I want to insert a row to the table if only the table is empty. I went through this Execute INSERT if table is empty? but am unable to do so.i am using MariaDB as rdbms.Please help.Thanks in advance.
Here is my sql syntax:
INSERT INTO `policy` (`policy1`, `policy2`, `policy3`, `policy4`)
SELECT ('F', 'F', 'F', 'F')
WHERE NOT EXISTS (SELECT * FROM `policy`)
My table structure is:
CREATE TABLE `policy` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`policy1` varchar(255) DEFAULT NULL,
`policy2` varchar(255) DEFAULT NULL,
`policy3` varchar(255) DEFAULT NULL,
`policy4` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1