node-adodb icon indicating copy to clipboard operation
node-adodb copied to clipboard

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

Open frmichetti opened this issue 3 years ago • 2 comments

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 avatar Nov 16 '21 17:11 frmichetti

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

frmichetti avatar Nov 17 '21 12:11 frmichetti

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.

dlh2 avatar Jan 12 '22 14:01 dlh2