views:

65

answers:

2

With SQL Server, I can send

SELECT * FROM FOO
SELECT * FROM BAR

to the server and get back the results of both, all in one trip.

Can I do that with mySQL also?

+1  A: 

As long as the queries have the same number of columns you can do a UNION on the two queries, e.g.

SELECT * FROM foo 
UNION
SELECT * FROM bar
Paul Dixon
Corey Tragers syntax, in SQL Server, would return two recordsets - quite probably with different columns in each - so in the application you could first do a NextRecord loop to process the first recordset, and then a NextRecordSet to get to the second.
Kristen
+3  A: 

I can only speak about the mysqli-extension for PHP, but I guess the same will be possible with most mysql-libraries. In PHP, you can send multiple queries, like

SELECT * FROM foo; SELECT * FROM bar;

with mysqli_multi_query() and iterate through the result-sets with mysqli_next_result().

mooware