I have the following two tables. The 'tracks' table has no artist/track names (thery are all currently NULL). I want to update 'tracks' with the artist_name and track_name from the 'names' table. The 'names' table has 242,416,787 records and the tracks table has about 4 million. The arist/track name is associated by track_id, so I only want entries form 'names' that I have track_ids for.
CREATE TABLE tracks (
s3_url VARCHAR(128),
track_id INTEGER KEY,
cluster_id INTEGER KEY,
rank INTEGER KEY,
group_id VARCHAR(128),
artist_name VARCHAR(128),
track_name VARCHAR(128),
set_name VARCHAR(128),
file_size INTEGER KEY);
CREATE TABLE names (
artist_name VARCHAR(128),
track_name VARCHAR(128),
track_id INTEGER KEY,
album_name VARCHAR(128));
Here's what I have so far, this gets me the records in 'names' that I have track_ids for:
SELECT names.artist_name, f.track_id FROM names INNER JOIN tracks AS f ON names.track_id=f.track_id
I can't get figure out how to then stuff those results back into the 'tracks' table. I was trying something to the effect of the following:
UPDATE x SET artist_name=SELECT names.artist_name, f.track_id FROM names INNER JOIN tracks AS f ON names.track_id=f.track_id) AS x;
These threads here, and here to accomplish similar things and show that JOIN/UPDATE is not supported in SQLite.
The desired end result is to populate all entries in 'tracks' with artist_name and track_name from 'names'.