我无法在一个查询中找到更新三个表的答案。 我有三个名为order1,order2,order3.in的表,每个表都有固定的所有列字段,如teacher_name,kitname,kit_quantity,total_amt,paid。 现在我想将付费列记录更新为"付费"哪里有人使用条件。 任何人都可以帮助我。我真的需要完成这个项目。这些表格如下:
order1
id teacher_name kitname kit_quantity total_amt paid
1 Amrish Bhoi product 1 2 600 unpaid
2 Geeta Naik product2 5 4500 paid
3 geeta naik product1 2 100 unpaid
4 Amrish Bhoi product3 1 200 paid
order2
id teacher_name kitname kit_quantity total_amt paid
1 Shindhu Sakpal product 3 2 600 Paid
2 Geeta Naik product2 5 4500 paid
3 geeta naik product1 2 100 unpaid
4 Amrish Bhoi product3 4 200 unpaid
order3
id teacher_name kitname kit_quantity total_amt paid
1 Amrish Bhoi product 1 2 600 unpaid
2 Geeta Naik product2 5 4500 paid
3 Harsha Kale product4 3 1800 unpaid
4 Amrish Bhoi product3 1 200 paid
5 Amrish Bhoi product3 1 600 unpaid
答案 0 :(得分:0)
要使用three tables
更新same structure
,different names
,您可以使用list of table names
并使用foreach loop
,如下所示:
<?php
$tableNames = array("order1", "order2", "order3");
foreach($tableNames as $table)
{
$query = 'UPDATE '.$table.' SET paid = "Paid" WHERE paid = "unpaid"';
mysqli_query($dbCon, $query);
}
?>