Connecting Tech Pros Worldwide Help | Site Map

Self Join error

  #1  
Old November 7th, 2007, 07:45 PM
Tangz
Guest
 
Posts: n/a
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

  #2  
Old November 7th, 2007, 09:25 PM
Salad
Guest
 
Posts: n/a

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 Threads
Thread Thread Starter Forum Replies Last Post
Weird record level locking with a self join Paul H answers 1 March 19th, 2008 05:05 AM
Self Joins in Access - Error Encountered. Darragh answers 2 February 18th, 2008 12:25 PM
Self Join in DB2 SQL Pragathiarun answers 1 June 30th, 2007 03:43 PM
self join error Aneri answers 0 March 1st, 2007 08:37 AM