sql - GROUP BY with MIN on multiple JOINS tables -



sql - GROUP BY with MIN on multiple JOINS tables -

i using sqlite , have problem making right query request in next scenario:

i have 4 tables, let's phone call them t.a, t.b, t.c, t.d

t.c in multiple 1 relation t.d, t.c has column called parent_id_d

t.a , t.c in multiple multiple relation each other created junction table called t.b link them each other.

now want create query request returns joined rows t.a , t.d each row should have distinct entries in id_a column table t.a , id_d column table t.d (or parent_id column t.c, same), distinct id_a, id_d want rows table returned should utilize group by min or max stated in reply distinct clause in sqlite can't working

i managed resolve query:

select * t_a inner bring together (select distinct id_parent_a, id_parent_d t_b inner bring together t_c on id_parent_c= ic_c) on id_a = id_parent_a inner bring together t_d on id_parent_d = id_d

where:

id_parent_a column in t_b foreign key t_a id_parent_c column in t_b foreign key t_c id_parent_d column in t_c foreign key t_d

sql sqlite

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -