PostgreSQL single query SELECT single row FROM two tables without JOIN -
the result of query need create return single row. data need pull comes 2 tables without relational columns. second table has additional rows added once per year i'll construct query via php necessary.
i know how use sql sub-selects i'm not sure how select
multiple columns from
second table when there no relational data in performance oriented/dynamic way.
here static example use multiple sub-selects visualize i'm trying do...
select t1.a, t1.b, t1.c, (select t2.d table2) d, (select t2.e table2) e, (select t2.f table2) f, (select t2.g table2) g, t1.h, t1.i table1 t1;
how dynamically , efficiently pull multiple columns second table has no relational columns first table?
i not want create second separate query cheap solution, have some impact on performance , worst of wouldn't expand understanding of sql.
sounds need cartesian join (no join) -- multiply values (ie, if table 1 has 100 rows , table 2 has 10 rows, you'll return 1000 rows)
select t1.a, t1.b, t1.c, t2.d, t2.e, t2.f, t2.g, t1.h, t1.i table1 t1, table2 t2;
Comments
Post a Comment