Connecting Tech Pros Worldwide Help | Site Map

Self Join error

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 7th, 2007, 06:45 PM
Tangz
Guest
 
Posts: n/a
Default Self Join error

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, 08:25 PM
Salad
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.