views:

42

answers:

2

I have two postgres queries that i execute using PHP and both of them result a Resource, is it possible to combine or concatenate these two resources?

+3  A: 

If the queries produce the same resultset layout (same number of columns, all of same types), then you can concatenate the queries:

SELECT   *
FROM     mytable1
WHERE    ...
UNION ALL
SELECT   *
FROM     mytable2
WHERE    ...
Quassnoi
A: 

If one or both queries give a single row of output but have different formats, then it may be more efficient to use cartesian product to retrieve the values in a single operation, e.g.

SELECT singlerow.*, multirow.*
FROM singlerow, multirow
WHERE singlerow.id=1
AND mutlrow.value>10;

C.

symcbean