nuintun / node-adodb

A node.js javascript client implementing the ADODB protocol on windows.
https://nuintun.github.io/node-adodb
MIT License
185 stars 51 forks source link

Query works on Access Database but not work in node-adodb #462

Open frmichetti opened 2 years ago

frmichetti commented 2 years ago

I have a query nested inside my database working perfectly. When I try to run on node-adodb it doesn't return any results and also doesn't show any error.

Query source table [All Games List API]: SELECT * FROM (SELECT [Origin Games].idx AS idx,[Origin Games].title AS title, "Origin" AS system, CBOOL([Origin Games].finished) AS finished FROM [Origin Games] UNION SELECT [Steam Games].[appid] AS appid, [Steam Games].[title] AS title, "Steam" AS system, CBOOL([Steam Finished].finished) AS finished FROM [Steam Games] INNER JOIN [Steam Finished] ON [Steam Games].[appid] = [Steam Finished].[appid] UNION SELECT [Wii GC Games].idx AS idx,[Wii GC Games].title AS title, [Wii GC Games].iso_type AS system, CBOOL([Wii GC Games].finished) AS finished FROM [Wii GC Games] UNION SELECT [WiiU Games].idx AS idx, [WiiU Games].title AS title, "WiiU" AS system, CBOOL([WiiU Games].finished) AS finished FROM [WiiU Games] UNION SELECT [Ubisoft Games].idx AS idx, [Ubisoft Games].title AS title, "Ubisoft" AS system, CBOOL([Ubisoft Games].finished) AS finished FROM [Ubisoft Games] ) AS ALL_GAMES ORDER BY ALL_GAMES.title, ALL_GAMES.system; This query works perfectly.

Now when I try to run the following query in ado-db:

SELECT * FROM [All Games List API] WHERE title Like "*Assa*"; No error is returned and no data is returned. But when executing this query inside the database it works normally.

frmichetti commented 2 years ago

Today I did a test, I renamed the table names replacing spaces with underline. Even so the query doesn't return data.

dlh2 commented 2 years ago

Hi, I think what you need is parenthesis on the FROM part and also by each UNION part.

Take this Query as an example:

SELECT a.animal, p.name, v.name
FROM (animals a INNER JOIN person p ON a.owner=p.id)
INNER JOIN  vets v ON a.vet = v.id 

Note: I don't know why Access does need this.