473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

Nov 7 '07 #1
1 1243
Tangz wrote:
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

Nov 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
4
by: Shahzad | last post by:
dear respected gurus, I would like to knew how to apply append,insert query for a self table where no primary keys issues. i do have problem say there are 5 rows of single record, this is data...
6
by: davegb | last post by:
I'm trying to create a self-join table to show the relationship between employee and supervisor. In another thread, I was advised to create a SupervisorID in the employee table, a separate...
2
by: Ev | last post by:
I have a database table in SQL Server that has a self join. In C# I have a DataTable with a self-join. I have defined a foreign key constraint on the DataTable for the self join. The...
3
by: sks | last post by:
I have a table that contains keywords (Varchars) each one mapped to a product. so the database schema is just an id column, product column and keyword column. I want to select the products that...
3
by: Genalube | last post by:
All right I am new at access but why would my calculated fields in my query self destruct all of a sudden? I tested these expressions, saved the query and closed it. I reopened them and tested it. ...
84
by: braver | last post by:
Is there any trick to get rid of having to type the annoying, character-eating "self." prefix everywhere in a class? Sometimes I avoid OO just not to deal with its verbosity. In fact, I try to...
2
by: Darragh | last post by:
Hi all! I'm having a bit of an issue making a self join in access (similar to the example explained on Allen Browne's excellent site - http://allenbrowne.com/ser-06.html). I've made the self...
1
by: Paul H | last post by:
I have an Employees table with the following fields: EmployeeID SupervisorID Fred Bob Bob John Bob Mary Bill Bill I have created a self join in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.