mariadb insert if not exists code example

Example 1: mariadb create index if not exists

CREATE INDEX IF NOT EXISTS index_name ON table_name(column_name)

Example 2: mysql insert if not exists

INSERT IGNORE INTO companies
    (id, full_name, address, phone_number)
VALUES
    (1, 'Apple', '1 Infinite Loop, Cupertino, California', 18002752273);

Example 3: php sql insert into if not exists

INSERT IGNORE INTO `transcripts`
SET `ensembl_transcript_id` = 'ENSORGT00000000001',
`transcript_chrom_start` = 12345,
`transcript_chrom_end` = 12678;

Tags:

Php Example