mysql create if not exists code example
Example 1: not exists mysql
SELECT DISTINCT store_type FROM stores
WHERE NOT EXISTS (SELECT * FROM cities_stores
WHERE cities_stores.store_type = stores.store_type);
Example 2: mysql create table if not exists
CREATE TABLE [IF NOT EXISTS] table_name(
column_1_definition,
column_2_definition,
...,
table_constraints
) ENGINE=storage_engine;
Example 3: mysql insert if not exists
INSERT IGNORE INTO companies
(id, full_name, address, phone_number)
VALUES
(1, 'Apple', '1 Infinite Loop, Cupertino, California', 18002752273);