Connecting Tech Pros Worldwide Help | Site Map

Self Join error

Tangz
Guest
 
Posts: n/a
#1: Nov 7 '07
Hi all,

I am trying to do a simple insert into query that inserts data from
one table to itself. Here is the design of my table:

Batch_Desc - Primary Key
Item_Total
Desc
Subtotal

What i am trying to do is strip a few characters from Batch_Desc using
Left(Batch_Desc, 12) and append that to Desc column. Here is my query:

INSERT INTO Works_Batch ( [Desc] )
SELECT Left([a].[Batch_Desc],12) AS [Desc]
FROM Works_Batch INNER JOIN Works_Batch AS a ON Works_Batch.Batch_Desc
= a.Batch_Desc;

When i run this query i receive an error stating that records cannot
be append due to key violations. As far as i can tell the query looks
fine to be. Does anyone have any idea why there is a problem with this
self join?

Thanks
Thangam

Salad
Guest
 
Posts: n/a
#2: Nov 7 '07

re: Self Join error


Tangz wrote:
Quote:
Hi all,
>
I am trying to do a simple insert into query that inserts data from
one table to itself. Here is the design of my table:
>
Batch_Desc - Primary Key
Item_Total
Desc
Subtotal
>
What i am trying to do is strip a few characters from Batch_Desc using
Left(Batch_Desc, 12) and append that to Desc column. Here is my query:
>
INSERT INTO Works_Batch ( [Desc] )
SELECT Left([a].[Batch_Desc],12) AS [Desc]
FROM Works_Batch INNER JOIN Works_Batch AS a ON Works_Batch.Batch_Desc
= a.Batch_Desc;
>
When i run this query i receive an error stating that records cannot
be append due to key violations. As far as i can tell the query looks
fine to be. Does anyone have any idea why there is a problem with this
self join?
>
Thanks
Thangam
>
Do you permit duplicates? Look at your table desing for Works_Batch and
remove the Unique index

Closed Thread


Similar Microsoft Access / VBA bytes