我有 3 个 MYSQL 表 wp_tabl1、wp_tabl2 和 wp_tabl3。
每个表有 5 列,如下所示 -day, date, examtype, student name
day | date | examtype | student name
Mon |01-07/2020| type1 | George
Mon |04-07/2020| type1 | Mary
Mon |04-07/2020| type3 | Anne
Mon |04-07/2020| type1 | Paul
Mon |04-07/2020| type3 | Julian
Mon |04-07/2020| type4 | Timmy
这是我到目前为止所拥有的:
<th colspan="5" style="text-align:center;"> <h2 class="exmm">EXAMS </h2> </th>
<tr>
<th>Day</th>
<th>Date</th>
<th>Exam Type</th>
<th>Student Name</th>
</tr>
<?php
global $wpdb;
$result = $wpdb->get_results (
"SELECT * FROM wp_tabl1
WHERE date=DATE(NOW())
UNION ALL
SELECT * FROM wp_tabl2
WHERE date=DATE(NOW())
UNION ALL
SELECT * FROM wp_tabl3
WHERE date=DATE(NOW())
ORDER BY examtype ASC;" );
foreach ( $result as $print ) {
?>
<tr>
<td><?php echo $print->day;?></td>
<td><?php echo $print->date;?></td>
<td><?php echo $print->examtype;?></td>
<td><?php echo $print->studentname;?></td>
</tr>
<?php }
?>
问题 - 我不想返回多个值examtype
鉴于它有一些重复项。
预期输出HTML
format
day | date | examtype | student name
Mon |04-07/2020| type1 | Mary
Mon |04-07/2020| | Paul
Mon |04-07/2020| type3 | Anne
Mon |04-07/2020| | Julian
Mon |04-07/2020| type4 | Timmy
请注意,它返回一个值examtype
对于每个组。
请帮我解决这个问题,非常感谢您的帮助。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)