0

大家好,

       for()
          {
            SELECT * from x union select * from y union select * from z
          }

我将联合添加到所有其他查询中,当 for 循环运行但在我的最后一行中,我必须删除联合,如何做到这一点。

提前致谢!

4

1 回答 1

1

您没有提供太多可使用的信息,但我假设您从一组查询字符串开始。如果是这样,试试这个:

$queries = array();
$queries[] = "SELECT * FROM x";
$queries[] = "SELECT * FROM y";
$queries[] = "SELECT * FROM z";

$query = implode(" UNION ", $queries);

// $query now contains "SELECT * FROM x UNION SELECT * FROM y UNION SELECT * FROM z"
于 2012-05-01T16:02:55.257 回答