The result of a query I need to create will only return a single row. The data I need to pull comes from two tables without any relational columns. The second table only has additional rows added once per year so I'll construct the query via PHP as necessary.
I know how to use SQL sub-SELECTs however I'm not sure how to SELECT multiple columns FROM a second table when there is no relational data in a performance oriented/dynamic way.
Here is a static example where I use multiple sub-SELECTs to visualize what I'm trying to do...
SELECT t1.a,
t1.b,
t1.c,
(SELECT t2.d FROM table2) AS d,
(SELECT t2.e FROM table2) AS e,
(SELECT t2.f FROM table2) AS f,
(SELECT t2.g FROM table2) AS g,
t1.h,
t1.i
FROM table1 AS t1;
How do I dynamically and efficiently pull multiple columns from a second table that has no relational columns with the first table?
I do not want to create a second separate query as it would be cheap solution, most likely have some impact on performance and worst of all I wouldn't expand my understanding of SQL.