Alasql: Subquerys dont work as expected

Created on 4 Apr 2017  路  5Comments  路  Source: agershun/alasql

I see statements like this dont work

SELECT (SELECT Name from SomeKindOfTable as sm WHERE sm.Id=m.Id)
FROM Main as m

Is it bug or not supported ?

! Bug Code provided to reproduced IndexedDB

Most helpful comment

Joins are slow if you only need 1 column. I dont want to join whole table to other table. Normly all sql engines allows you to do that like i showed.

All 5 comments

ps I use indexeddb database.

Hmm. Does this work in other databases? Looks like you are doing a join without doing a join.

I would be really awesome if you could provide an example with the data in sm and m together with the expected output...

Have you tested with its not indexeddb?

SELECT HardServiceId,
h.ClientId,
h.Name,
h.Date AS RegDate,
h.Duration AS EndTime,
h.VisitDate AS PlanDate,
h.Address,
h.City,
(SELECT op.Name
FROM Options_Details as op
WHERE op.OptionDetailId = h.ServiceId) AS Type,

(SELECT op.Name
FROM Options_Details as op
WHERE op.OptionDetailId = h.StatusId) AS Status
FROM HardService as h

before I used sql.js https://github.com/kripken/sql.js/

now Iam doing

JOIN Options_Details as opse ON opse.OptionDetailId=h.ServiceId
JOIN Options_Details as opst ON opst.OptionDetailId=h.StatusId

because subselects dont work

javascript code:
alasql('ATTACH INDEXEDDB DATABASE database;USE database;', [],function(){
// Select data from IndexedDB
alasql.promise(sql_statement))
.then(callback);
});
sql_statement is SQL select above

Joins are slow if you only need 1 column. I dont want to join whole table to other table. Normly all sql engines allows you to do that like i showed.

I could be wrong about speeds :) in internal. but anyway subselect should work 馃槃 .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carloszimm picture carloszimm  路  3Comments

mwhebert picture mwhebert  路  3Comments

mathiasrw picture mathiasrw  路  5Comments

umasudhan picture umasudhan  路  4Comments

thierrygervais picture thierrygervais  路  6Comments