How can I create an IF statement that will insert a default row if a table is found to be empty? I'm following this logic but something is wrong.
IF ((SELECT * FROM myTable)=0)
THEN
INSERT INTO myTable
(myColumn) VALUES (myValue)
END IF;
#1064 - 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
Answer from comments (McAdam331) http://sqlfiddle.com/#!9/42229/1
CREATE TABLE myTable(
name VARCHAR(100));
INSERT INTO myTable (`name`)
SELECT 'namer'
FROM DUAL
WHERE NOT EXISTS (SELECT * FROM myTable);