I have three tables, representing two entities and a connection relationship. Each of the entity relations has an artificial surrogate key used for foreign key constraints in place of natural keys.
...

I am playing around with some stuff in SSMS to learn a little more as I study for my 70-461 exam and I came across a little hangup. I am trying to create a table to play around with so I don't have to ...

I working on a medium sized PostgreSQL database with some schemas, each with some tables.
In almost every schema there are tables that represent event tables, where something that has "happened to" ...

I want to build a function which will insert an email if the email value doesn't exist in the table and return the email_id of the row. How can I do this?
Also how can I return the id if the email was ...

On the percona-5.6 and MariaDB-10.0 servers, the NOT NULL declared on table field are being ignored. I am able to leave fields declared as NOT NULL empty when inserting data and the servers are not ...

I need to insert some records derived from relationships in the same "pivot" table.
We have a products_to_products table which stores relationships between products.
Here's a simplified example (also ...

We have a job that populates about 450,000 rows nightly in an update/insert job via a stored proc nightly. The .Net app pulls in data from a noSQL DB via an API call then pushes it out via a stored ...

Setting
In a datawarehouse, I am joining a fact table to 20 dimensions. The fact table has 32 million rows and 30 columns. This is a temporary staging table so I don't have to deal with other users ...

In pq 9.3.5, I'm importing records from an external source where duplicates are VERY rare, but they do happen. Given a readings table with a unique compound key on (real_time_device_id, recorded_at), ...

I have a dataset of 233,902,846 rows in a csv file.
I want to load the data into mysql table. What is the most efficient way of transferring the data so that data insertion is the fastest. actually ...

I've got a problem on SQL Server 2008 where I'm getting a duplicate key entry error on a process that's worked fine in the past. What is really weird is that if I drop the clustered index, insert the ...

I am trying to import from 8 files and insert into a single table in db2. I am running 8 .sql files that will do the task, but only one of them actually seem to be running and inserting into table.
...

Here's the original question regarding PostgreSQL. I'd like to know of a similar solution for MySql.
The simplest syntax provided in the answer works fine as long as the relevant rows already exist ...

we have a work table that stores availability of products. This table is updated with millions of inserts every night and medium amounts of inserts throughout the day.
during the updates, we delete ...