简体   繁体   English

PHP + MYSQL:从(进入)许多表中选择/更新/插入

[英]PHP + MYSQL: select/update/insert from(into) many tables

I'm having many tables (shall we call them tableN ) with fields: id , valueN . 我有很多表(我们称之为tableN )字段: idvalueN Assume that we have array (value1 => 'val1', value2 => 'val2', value10 => 'val10') , what is the way to insert values into table1 , table2 and table10 (I mean something better then doing 3 requests to DB). 假设我们有数组(value1 => 'val1', value2 => 'val2', value10 => 'val10') ,将值插入table1table2table10是什么(我的意思是做3个请求更好的方法)到DB)。 What is the simpliest way to update values in tables from row (of cause if we know id ). 从行中更新表中的值的最简单方法是什么(如果我们知道id ,则是原因)。 And finally what is the most elegant way to get all values with id=ID from tables ( JOIN ?). 最后,从表中获取id=ID所有值的最优雅方法是什么( JOIN ?)。

Thank you in advance! 先感谢您!

The simplest way is to write 3 seperate insert statements into the three tables. 最简单的方法是在三个表中写入3个单独的插入语句。 That is the way to do it. 这是做到这一点的方法。

If required wrap them in a transaction. 如果需要将它们包装在一个事务中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM