clear markdown help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1716874 fiddles created (23891 in the last week).

CREATE TABLE countries (id INT, name VARCHAR(255)) SELECT 123 id, 'Russia' name UNION SELECT 456, 'Papua'; SELECT * FROM countries; CREATE TABLE languages (country_id INT, name VARCHAR(255), language_code CHAR(5)) SELECT 123 country_id, 'Russia' name, 'ru-ru' language_code UNION SELECT 456, 'Papua', 'pa-pa'; SELECT * FROM languages;
id name
123 Russia
456 Papua
country_id name language_code
123 Russia ru-ru
456 Papua pa-pa
id name
123 Russia
456 Papua
country_id name language_code
123 Russia ru-ru
456 Papua pa-pa
 hidden batch(es)


insert into languages (country_id, name, language_code) select (select id from countries where name = 'Russia'), 'Russian', 'ru-ru' where not exists (select * from languages where country_id = (select id from countries where name = 'Russia') and name = 'Russian'); SELECT * FROM countries; SELECT * FROM languages;
id name
123 Russia
456 Papua
country_id name language_code
123 Russia ru-ru
456 Papua pa-pa
123 Russian ru-ru
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where not exists (select * from languages where country_id = (select id from...' at line 3
 hidden batch(es)