Skip to main content
Inspiring
May 5, 2009 3:04 PM UTC
Answered

Best approach to join multiple statistics tables into one

I have read different approaches to join multiple statistics tables into one, they all have a column "productobjectid".

I want to get all data for each product and put it to excel and output a jpg statistic with cfchart.

How would you do this, the sql part?

Thanks.

This topic is closed to new replies. Start a new post to keep the conversation going.
insuractiveCorrect answer
Inspiring
May 5, 2009 9:10 PM UTC

Your "abiguous" error is caused when you are referencing multiple tables in your SQL statement that have the same field name.

e.g.

TableA has field "ID"

TableB also has a field called "ID"

If your select statement was:

SELECT *

FROM TableA inner join TableB on TableA.myField = TableB.myField

WHERE ID = 4

then SQL would freak out because it wouldn't know which ID field in which table you are trying to access.  Your best bet is to always prefix your field names with the name of your table (or an alias - aliases are very useful if you have long table names) when doing a Select statement.

6 replies

ilssac
Inspiring
May 5, 2009 3:17 PM UTC

SQL joins would be my first choice.

Translate
Inspiring
May 5, 2009 8:45 PM UTC

Could you give a example, i try to use a multiple join but keep running into a "Column blabla in from clause is ambiguous" error...

Translate
insuractiveCorrect answer
Inspiring
May 5, 2009 9:10 PM UTC

Your "abiguous" error is caused when you are referencing multiple tables in your SQL statement that have the same field name.

e.g.

TableA has field "ID"

TableB also has a field called "ID"

If your select statement was:

SELECT *

FROM TableA inner join TableB on TableA.myField = TableB.myField

WHERE ID = 4

then SQL would freak out because it wouldn't know which ID field in which table you are trying to access.  Your best bet is to always prefix your field names with the name of your table (or an alias - aliases are very useful if you have long table names) when doing a Select statement.

Translate