Unable to run an INSERT query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

This query hangs in the middle of executing. Can anybody see or explain
what's wrong, please?

INSERT INTO HIPlanNames
SELECT [2004_HiPlanNames_ADD].*
FROM 2004_HiPlanNames_ADD, HiPlanNames;

This comes after the following table was created:
SELECT HiPlanNames_2004_Final.* INTO 2004_HiPlanNames_ADD
FROM HiPlanNames_2004_Final
WHERE (((Left([Source1],2))="03" Or (Left([Source1],2))="04")) OR
(((Left([Source2],2))="03" Or (Left([Source2],2))="04")) OR
(((Left([Source3],2))="03" Or (Left([Source3],2))="04")) OR
(((Left([Source4],2))="03" Or (Left([Source4],2))="04")) OR
(((Left([Source5],2))="03" Or (Left([Source5],2))="04")) OR
(((Left([Source6],2))="03" Or (Left([Source6],2))="04")) OR
(((Left([Source7],2))="03" Or (Left([Source7],2))="04")) OR
(((Left([Source8],2))="03" Or (Left([Source8],2))="04")) OR
(((Left([Source9],2))="03" Or (Left([Source9],2))="04")) OR
(((Left([Source10],2))="03" Or (Left([Source10],2))="04"));
 
Do you really want a Cartesian join in your SELECT statement? That can
generate a very large number of records since it will create one record for
every combination of records in the two tables. For example, if HiPlanNames
has 4000 records and 2004_HiPlanNames_ADD has 200, you will end up with
800000 records being added to HiPlanNames.

I suspect you want

INSERT INTO HIPlanNames
SELECT [2004_HiPlanNames_ADD].*
FROM 2004_HiPlanNames_ADD
 
Dear Luther:

Just to avoid confusion, it looks to me that John has said the same thing
that I did in your other thread. A Cartesian join is the same as a cross
product.

Tom Ellison


John Spencer said:
Do you really want a Cartesian join in your SELECT statement? That can
generate a very large number of records since it will create one record
for every combination of records in the two tables. For example, if
HiPlanNames has 4000 records and 2004_HiPlanNames_ADD has 200, you will
end up with 800000 records being added to HiPlanNames.

I suspect you want

INSERT INTO HIPlanNames
SELECT [2004_HiPlanNames_ADD].*
FROM 2004_HiPlanNames_ADD

Luther said:
Hi,

This query hangs in the middle of executing. Can anybody see or explain
what's wrong, please?

INSERT INTO HIPlanNames
SELECT [2004_HiPlanNames_ADD].*
FROM 2004_HiPlanNames_ADD, HiPlanNames;

This comes after the following table was created:
SELECT HiPlanNames_2004_Final.* INTO 2004_HiPlanNames_ADD
FROM HiPlanNames_2004_Final
WHERE (((Left([Source1],2))="03" Or (Left([Source1],2))="04")) OR
(((Left([Source2],2))="03" Or (Left([Source2],2))="04")) OR
(((Left([Source3],2))="03" Or (Left([Source3],2))="04")) OR
(((Left([Source4],2))="03" Or (Left([Source4],2))="04")) OR
(((Left([Source5],2))="03" Or (Left([Source5],2))="04")) OR
(((Left([Source6],2))="03" Or (Left([Source6],2))="04")) OR
(((Left([Source7],2))="03" Or (Left([Source7],2))="04")) OR
(((Left([Source8],2))="03" Or (Left([Source8],2))="04")) OR
(((Left([Source9],2))="03" Or (Left([Source9],2))="04")) OR
(((Left([Source10],2))="03" Or (Left([Source10],2))="04"));
 
Thank you both so much....It worked. This was a major mistake of my part. I
don't know where I got it that I had to include both files in the FROM
clause....Trying to remember too much syntax.

Luther

Tom Ellison said:
Dear Luther:

Just to avoid confusion, it looks to me that John has said the same thing
that I did in your other thread. A Cartesian join is the same as a cross
product.

Tom Ellison


John Spencer said:
Do you really want a Cartesian join in your SELECT statement? That can
generate a very large number of records since it will create one record
for every combination of records in the two tables. For example, if
HiPlanNames has 4000 records and 2004_HiPlanNames_ADD has 200, you will
end up with 800000 records being added to HiPlanNames.

I suspect you want

INSERT INTO HIPlanNames
SELECT [2004_HiPlanNames_ADD].*
FROM 2004_HiPlanNames_ADD

Luther said:
Hi,

This query hangs in the middle of executing. Can anybody see or explain
what's wrong, please?

INSERT INTO HIPlanNames
SELECT [2004_HiPlanNames_ADD].*
FROM 2004_HiPlanNames_ADD, HiPlanNames;

This comes after the following table was created:
SELECT HiPlanNames_2004_Final.* INTO 2004_HiPlanNames_ADD
FROM HiPlanNames_2004_Final
WHERE (((Left([Source1],2))="03" Or (Left([Source1],2))="04")) OR
(((Left([Source2],2))="03" Or (Left([Source2],2))="04")) OR
(((Left([Source3],2))="03" Or (Left([Source3],2))="04")) OR
(((Left([Source4],2))="03" Or (Left([Source4],2))="04")) OR
(((Left([Source5],2))="03" Or (Left([Source5],2))="04")) OR
(((Left([Source6],2))="03" Or (Left([Source6],2))="04")) OR
(((Left([Source7],2))="03" Or (Left([Source7],2))="04")) OR
(((Left([Source8],2))="03" Or (Left([Source8],2))="04")) OR
(((Left([Source9],2))="03" Or (Left([Source9],2))="04")) OR
(((Left([Source10],2))="03" Or (Left([Source10],2))="04"));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top