I’m trying to perform a somewhat complex select from 3 tables, all joined by a b_id:
select max(bs.b_id),
h.b_type_id,
t.name_id
from b_state as bs,
t_info as t,
history as h
where bs.b_id = t.b_id
and bs.b_id = h.b_id
and t.name_id in (???)
and bs.is_detached = ?
group by h.b_type_id,
t.name_id
In MySQL it gives exactly what I want, but it seems to fail in PSQL and Oracle, plus execution in Oracle results in: “ORA-00933: SQL command not properly ended” (which usually occurs in INSERT queries as Google suggests).
I suppose there is a DB independent way to do the same. Please advice.
Try: