定义哪个类型选择union mysql php

问题描述 投票:-1回答:2
SELECT column1, column2, column3, column4, column5 FROM table1 WHERE column2 = :value 
UNION SELECT column1, column2, column3, column4, column5 FROM table2 WHERE column2 = :value 

所以我有这个查询,这是我的PHP:

<?php
if(isset($this->info)){
    foreach ($this->info as $infor){ ?>
    <tr>
    <td><?= $infor->column1 ?></td>
    <td><?= $infor->method ?></td>
    <td><?= $infor = ($infor->column3 == 1) ? 'Completed' : 'Incompleted'; ?></td>
    <td><?= $infor->column4 ?></td>
    <td>$<?= number_format($infor->amount, 2, '.', ''); ?></td>
    </tr>
<?php } } ?>

现在你看到<td><?= $infor->method ?></td>

我想在这里展示如果是来自table1或table2,我该怎么做?

php mysql sql
2个回答
© www.soinside.com 2019 - 2024. All rights reserved.