开发者

Combining two resources PHP

开发者 https://www.devze.com 2022-12-18 07:21 出处:网络
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?If the queries produce the same r

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?


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    ...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消