How would I go on to do these mysql_querys
mysql_query("SELECT * FROM my_table_1");
mysql_query("SELECT * FROM my_table_2");
mysql_query("SELECT * FROM my_table_3");
mysql_query("SELECT * FROM my_table_4");
..and put all the results in a array and echo that array..?
Put multiple querys in array
Moderator: General Moderators
-
lammspillning
- Forum Newbie
- Posts: 14
- Joined: Fri Aug 17, 2007 10:50 am
Re: Put multiple querys in array
Assuming they all contain similar elements, try using a UNION query.
$qry = mysql_query("(SELECT * FROM table1) UNION (SELECT * FROM table2) UNION (SELECT * FROM table3)");
$results = mysql_fetch_array($qry);
Then you have your array!
***Here's another thought: I don't know what your data structure is like, but if you have multiple tables with similar data, I suspect it's not normalized properly. It might all belong in one table.
$qry = mysql_query("(SELECT * FROM table1) UNION (SELECT * FROM table2) UNION (SELECT * FROM table3)");
$results = mysql_fetch_array($qry);
Then you have your array!
***Here's another thought: I don't know what your data structure is like, but if you have multiple tables with similar data, I suspect it's not normalized properly. It might all belong in one table.