Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in Join operation 1

Status
Not open for further replies.

Tailgun

Technical User
Mar 30, 2002
417
US
here is the code that is giving me the error. I'm new to joins so maybe somone can help.

Select * FROM tblProjectLineItems INNER JOIN tblProjectLineItems ON tblPayAppLineItems.LineItemID = tblProjectLineItems.LineItemID
 
Uh, what error?

Anyway: be sure that both fields (blPayAppLineItems.LineItemID and tblProjectLineItems.LineItemID) are of the same datatype.
Also beware of 'SELECT *': it means you want to get all the fields of both tables, that might be more then you need.
At last: be sure both field are indexed...
 
Your join says that you are joining a table to itself
Viz.
[tt]
tblProjectLineItems INNER JOIN tblProjectLineItems
[/tt]

but your ON condition specifies different tables
Viz.
[tt]
ON tblPayAppLineItems.LineItemID = tblProjectLineItems.LineItemID
[/tt]

Either you want the same table with aliases
[tt]
Select *
FROM tblProjectLineItems A INNER JOIN tblProjectLineItems B
ON A.LineItemID = B.LineItemID
[/tt]

or different tables in the join
[tt]
Select *
FROM tblPayAppLineItems INNER JOIN tblProjectLineItems
ON tblPayAppLineItems.LineItemID = tblProjectLineItems.LineItemID
[/tt]
 
Go Golem! Completely overlooked that
 
Thanks Golem that did the trick for removing the error. But now for some reason I can't fill the grid with the information from that. :( I'm using Component One TDBGrid. I know I'm doing something wrong but don't know what it is.

Again thanks it sure did solve the problem with the INNER JOIN problem.
 
my bad :(:( It does work fine just didn't have anything in the LineItemID column in one of the tables.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top