View Single Post
  #1 (permalink)  
Old 09-07-04, 16:59
neptune48178 neptune48178 is offline
Registered User
 
Join Date: Aug 2004
Posts: 6
Insert Into Left Join

Hello everyone, I'm wondering if its possible to insert the result of a left join comparsion statement (see the following).

SELECT *
FROM demographics
LEFT JOIN demo ON demographics.MPI = demo.MPI
WHERE demo.MPI IS NULL;

The above statement compares demo vs. demographics and give me a list of records that are on demographics that are not in demo, this worked great.

Now I want to insert the result of that statement into demo, easier said than done I added INSERT INTO Demo in front of the statement above.

INSERT INTO demo
SELECT *
FROM demographics
LEFT JOIN demo ON demographics.MPI = demo.MPI
WHERE demo.MPI IS NULL;

#1136 - Column count doesn't match value count at row 1

These two tables are idenitcal the same table structure and field types. I know this because i copied the table and renamed one of them. The only differences between the two are demo has 15 records and demographics have 17 records. Can someone please point me at the right direction.

Thank you very much!!!

Joe
Reply With Quote