I have a single table with Id, the thing is that i need to provide N number of Ids (using WHERE id IN (1,5,101)) but i need to get the same number of records back (if i send 100 ids, i need a DataSet with 100 rows ..) even if Id doesn’t exist on this table.
I’m using SQLite so RIGHT JOIN is not an option.
Here is some sample of what i have but cant make it work :S ..
SELECT * FROM (
SELECT r.report_id, r.batch_name, tr.report_id id, tr.batch_name bn
FROM reports tr
LEFT OUTER JOIN ( SELECT report_id, batch_name FROM reports
WHERE batch_name IN ("L6964498","AAAAAA")) r on r.report_id = tr.report_id) as v
LEFT JOIN reports ON v.id = reports.report_id
Thanks in advance …
Make up a virtual table of batch names using
SELECT .. UNION ALL SELECT ... Then join that to yourreportstable.If you have 100 items, you will have 99
UNION ALLs.