Reputation: 47
Okay so I've got two tables named cars and insurance
The car table goes something like:
The insurance table goes something like:
type
reference_number
The insured table goes something like(is empty, to begin with):
brand
colour
The goal is to import all cars with insurance into the insured table.
So far all I could come up with is:
"SELECT cars.reference_number, insured.reference_number FROM INSPECTIONS LEFT JOIN insured ON cars.reference_number = cars.reference_number ORDER BY cars.reference_number")
Upvotes: 0
Views: 66
Reputation: 23797
From your explanation ("all cars with insurance") - insured have reference_number too, right?:
insert into insured (reference_number, brand, colour)
SELECT reference_number, brand, colour
FROM Cars
where reference_number in (select reference_number from insurance)
ORDER BY reference_number
Upvotes: 1