I know about insert ignore
. That's of no use, because MariaDB does not consider NULL to be part of the uniqude index.
Therefore I have to use if ... else
.
But this code does not run:
select *
from Nodes
where `Key` = 'FAQPage';
if not found_row() then
insert into Nodes (`Key`, ParentId)
values ('FAQPage', null)
end if;
How can I use if ... else
to conditionally insert data in MariaDB?
if ... else
issue.