I have the following query, that works on both MySQL and MariaDB:
INSERT into some_table (column1, column2, column3, column4, column5)
SELECT 'val1', 'val2', 'val3', 'val4', 'val5'
FROM `some_table`
WHERE NOT EXISTS (
SELECT `column1`, `column2` from `some_table`
WHERE `column1` = 'val1' and `column2` = 'val2'
) limit 1`
It checks if a row exists based on unique values for val1 and val2: If the row exists, the query does nothing. If the row doesn't exist, the query inserts a new row with the values of val1, val2, val3, val4 and val5.
The query works, unless the table is empty, in which case, no value is being inserted.
How can I modify this query to also work with an empty table?
(Note: I cannot create a unique index on this table)