database - Insert SQL statement on access which would let me extract data according to data from another table? -


so far i've managed extract data 1 table another.

 insert town ( town_name)  select distinct locality  students_record  locality <> null ; 

what tried there error locality not found or tried different methods sub queries dont seem return anything.

what i've thought like

first extracted town_names previous query, then...

            insert town(country)             select id country             town_name = (select locality students_record) ,             country_name = (select country students_record) 

the town table connected via country country id (country) country (town). difficulty i'm facing ;

i cannot automatically insert towns along country fk (the countries extracted students_records simple sql statement using distinct). town names being extracted table students_record denormalized table in i'm trying fix.

so question is... how indicate country id in insert statement correspond distinct locality (student_records) match country in student_records.

tables summary

country id pk auto number, country_name

town id pk, town_name, country fk,

students_records id, town, country , etc....

re-cap : country names extracted students_records.country (from table using distinct keyword)

town names extracted table using similar method.

town.country id must correspond same country name had town_name in same row.

use "is not null" instead of " <> null"


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -