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 ?
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 馃槃 .
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.