This is a bit different than the normal "You can't specify target table for update in FROM clause" questions. I know I need to create a temp table as part of the query to get around that, but I'm doing that as shown below and still getting that error.
LOAD DATA LOCAL INFILE 'filename.csv'
INTO TABLE campaigner.areas
CHARACTER SET latin1
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(abbr, fips_code, name)
SET area_type_id = @STATE_TYPE_ID,
description = NULL,
gnis_feature_id = NULL,
parent_id = (SELECT c.country_id FROM (SELECT country_id,country_abbr FROM campaigner.countries_v) AS c WHERE c.country_abbr = 'US'),
latitude = NULL,
longitude = NULL;
Here's the definition of countries_v, which, as you can see, does use the areas table.
CREATE OR REPLACE VIEW campaigner.countries_v (country_id, country_abbr, country_name, fips_code) AS
SELECT c.country_id, ca.abbr, ca.name, ca.fips_code
FROM campaigner.countries c
LEFT JOIN campaigner.areas ca ON c.country_id = ca.area_id;
What am I missing?