Skip to content
Advertisement

SQL select multiple arrays and populate one table

I am trying to pupulate 1 table with results from 2 select querys but from the same table. It is not working, one pupulates the other one shows only one result.. Is it posible to do this in one select as i think the problem is with the use of two fetch assoc.

Question: How do i get the result of both of these querys presented in the table i created?

JavaScript

Advertisement

Answer

You shouldn’t have nested loops, that’s creating a cross product between the two results, not processing them in parallel.

You should have a single loop that fetches a row from each query.

JavaScript

Note that if either of the queries returns less than 10 rows, the table will stop at the shorter length. If you want the longer length, use || in the while condition, and then check whether $rowrich or $rowrich2 is empty before outputting those columns.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement