通过一个 mysql 查询插入不同的表
我如何通过一个 mysql 查询插入 3 个不同的表,即我想编写一个 mysql 查询,该查询将插入 3 个不同的表.我基本上是 html 表单,其中涉及不同的表,因此我将插入收集的数据从一个表格变成 3 个不同的表格.有可能吗?如果不是为什么??
how can i insert in 3 different tables through one mysql query that is i want to write one mysql query that will insert in 3 different tables.i have basically html form in which there are different tables involved so i will insert data collected from a form into 3 different tables. is it possible if so how ?? if not why ??
一张桌子
$var1_table1 = $_POST['table1_column1'];
$var2_table1 = $_POST['table1_column2'];
$var3_table1 = $_POST['table1_column3'];
第二张桌子
$var1_table2 = $_POST['table2_column1'];
$var2_table2 = $_POST['table2_column2'];
$var3_table2 = $_POST['table2_column3'];
第三张桌子
$var1_table3 = $_POST['table3_column1'];
$var2_table3 = $POST['table3_column2'];
$var3_table3 = $_POST['table3_column3'];
这是我的变量的格式
据我所知,PHP 的 mysql_query() 函数不支持多个查询(插入、选择、更新等),并且当您插入到不同的具有不同字段/列的表,您必须为每个表运行单独的查询.我不认为有办法做你想做的事.
As far as I know, PHP's mysql_query() function doesn't support multiple queries (insert, select, update etc), and as you are inserting into different tables with different fields/columns, you have to run a separate query for each. I don't think there is a way to do what you want.