John Mamba
John Mamba

Reputation: 11

SQL #1066 - Not unique table/alias:

I'm getting this error with my code:

SELECT flatpack_ig,FlatpackID ,Name,Colour,Type,UnitPrice,component_ig,ComponentNo, component_ig,
description FROM flatpack_ig
INNER JOIN flatpackcomponent_ig
ON flatpack_ig, FlatpackID= flatpackcomponent_ig,FlatpackID
INNER JOIN component_ig
ON flatpackcomponent_ig, ComponentNo=component_ig,ComponentNo
ORDER BY flatpack_ig,FlatpackID

Upvotes: 1

Views: 58

Answers (2)

John Mamba
John Mamba

Reputation: 11

I think i found the solution not sure

SELECT flatpack_ig.FlatpackID ,Name,Colour,Type,UnitPrice,component_ig.ComponentNo, component_ig.Description FROM flatpack_ig INNER JOIN flatpackcomponent_ig ON flatpack_ig.FlatpackID= flatpackcomponent_ig.FlatpackID INNER JOIN component_ig ON flatpackcomponent_ig.ComponentNo=component_ig.ComponentNo

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1269693

Whenever you have multiple tables in a query, you should always qualify all column names. Something like this:

SELECT fp.FlatpackID, fp.Name, fp.Colour, fp.Type, fp.UnitPrice,
       c.ComponentNo, c.description
FROM flatpack_ig fp INNER JOIN
     flatpackcomponent_ig fpc
     ON fp.FlatpackID = fpc.FlatpackID INNER JOIN 
     component_ig c INNER JOIN
     flatpackcomponent_ig fpc 
     ON fpc.ComponentNo = c.ComponentNo
ORDER BY fp.FlatpackID;

I am guessing where the columns come from. My guesses may not be accurate.

Your query has multiple other problems as well. I am guessing that these are transcription errors -- commas instead of periods and misplaced keywords.

Upvotes: 1

Related Questions