Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi, I have problem with MS Query in Excel 2003.
I'm trying to get information from MySQL database to Excel with an SQL-clause that contains a few subqueries. For example, the following SQL-clause gives me an error saying: "Unknown column hours.hourssum in 'field list'" Query: SELECT orders.id AS id, hours.hourssum AS hourssum FROM orders LEFT JOIN (SELECT job.id AS id, sum(job.hours1) AS hourssum FROM job GROUP BY job.id) AS hours ON orders.id=hours.id WHERE orders.id = '123'; I know that the query above can be done a bit differently, but it's just an example of the problem I have. The problem is that MS Query can't see the table alias "hours" and gives me a complaint that it doesn't exist. Same SQL-clause works fine in MySQL Query Browser. Is there a way around this, maybe a different syntax in SQL-caluse or something else? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I solved the problem. Following query works fine:
SELECT orders.id AS id, hours.hourssum AS hourssum FROM (orders) LEFT JOIN (SELECT job.id AS id, sum(job.hours1) AS hourssum FROM job GROUP BY job.id) AS hours ON orders.id=hours.id WHERE orders.id = '123'; Only thing that is different are the brackets around orders-table, right after FROM-keyword. Thanks anyway "Finnman" wrote: Hi, I have problem with MS Query in Excel 2003. I'm trying to get information from MySQL database to Excel with an SQL-clause that contains a few subqueries. For example, the following SQL-clause gives me an error saying: "Unknown column hours.hourssum in 'field list'" Query: SELECT orders.id AS id, hours.hourssum AS hourssum FROM orders LEFT JOIN (SELECT job.id AS id, sum(job.hours1) AS hourssum FROM job GROUP BY job.id) AS hours ON orders.id=hours.id WHERE orders.id = '123'; I know that the query above can be done a bit differently, but it's just an example of the problem I have. The problem is that MS Query can't see the table alias "hours" and gives me a complaint that it doesn't exist. Same SQL-clause works fine in MySQL Query Browser. Is there a way around this, maybe a different syntax in SQL-caluse or something else? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Query from microsoft query- Excel 2007 | Excel Discussion (Misc queries) | |||
Importing Outlook Alias into an Excel 2003 macro | Excel Discussion (Misc queries) | |||
SQL query removes alias | Excel Discussion (Misc queries) | |||
Microsoft Excel Viewer 2003 won't open Microsoft Excel Worksheet | Excel Discussion (Misc queries) | |||
MS Query - Alias syntax | Excel Worksheet Functions |