0

I'm trying to get information from 2 tables with a SQL query..

SELECT Num_of_icon, ID_Radar, ID_Observer,
       Longitude_Impact_point, Latitude_Impact_point,
       Longitude_Impact_point_By_Cutting, Latitude_Impact_point_By_Cutting,
       Deviation_In_Meters,
       Longitude_Deviation, Latitude_Deviation,
       Longitude, Latitude, Azimuth
FROM ShowTable, Observer
ORDER BY Num_of_icon ASC

Num_of_icon is a key in one table.
ID_Observer is a key in the second table and a field in the first table.

The error is:

The field 'ID_Observer' should be show in more than one table.

I dont understand what this error is about.. I know that ID_Observer is showing more than one table, that's why I have a connection between the tables...

2 Answers 2

1

You have to qualify a column with tablename.columnname if a column exists in two tables. You also have to link both tables via JOIN:

SELECT Num_of_icon, 
       ID_Radar, 
       SHowTable.ID_Observer, --<<< HERE
       Longitude_Impact_point, 
       Latitude_Impact_point, 
       Longitude_Impact_point_By_Cutting, 
       Latitude_Impact_point_By_Cutting, 
       Deviation_In_Meters, 
       Longitude_Deviation, 
       Latitude_Deviation, 
       Longitude, 
       Latitude, 
       Azimuth 
FROM   ShowTable 
INNER JOIN Observer 
    ON ShowTabl.ID_Observer = Observer.ID_Observer  --<<< and HERE
ORDER  BY Num_of_icon ASC 
Sign up to request clarification or add additional context in comments.

Comments

0

The query processor does not know which of the ID_Observer fields it should take (and it doesn't make an effort to determine whether they will always be the same value regardless of which table it takes it from). So you'll have to specify this, ie the following will take the ID_Observer value from the Observer table:

"SELECT Num_of_icon,ID_Radar,Observer.ID_Observer,Longitude_Impact_point..."

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.