简体   繁体   English

使用where子句mysql将数据从一个表传输到另一个表

[英]Transferring data from one table to another using a where clause mysql

I would like to copy data from one table to another, but placing it in a specific row. 我想将数据从一个表复制到另一个表,但是将其放在特定的行中。 The variable is set, the tables and query are named correctly and the columns set up correctly. 设置了变量,正确地命名了表和查询,正确设置了列。

I would like to select the data circled in black 我想选择黑色圆圈中的数据

在此处输入图片说明

and place it within the section circled below in black 并将其放在下面用黑色圆圈圈出的部分内

在此处输入图片说明

The query I am using if below. 我在下面使用的查询。 When it runs without the WHERE clause it goes on the row below, when the WHERE clause is added it is blank. 当它运行时没有WHERE子句时,它将继续在下面的行中;当添加WHERE子句时,它将为空白。

$query = "INSERT INTO Results (Q1A) SELECT Q1AY FROM Answers WHERE User = $email";

Try 尝试

$query ="UPDATE Results R SET Q1A= (SELECT Q1AY FROM Answers) WHERE R.User=$email"

This only works if there are only one row in Answers, but your code seems to assume as much. 仅当“答案”中只有一行时,此方法才有效,但是您的代码似乎承担了很多。

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

相关问题 将数据从一个MySQL表传输到另一个MySQL表 - Transferring Data From One MySQL Table To Another 使用PHP和MySQL将信息从一个表转移到另一个表 - Transferring information from one table to another using PHP and MySQL Codeigniter 使用for循环将数据从一个表传输到另一个表 - Codeigniter transferring data from one table to another using for loop PHP MySQL使用where子句INSERT来自另一个表的数据,并将唯一值插入到相同的行中 - PHP MySQL INSERT data from another table using the where clause and insert unique values to the same rows 如何在另一个表的'where'子句中使用一个表的数据? - How to use data of one table in 'where' clause of another table? 从一个表中获取所有数据,而另一个表为空并且还应用where子句 - Getting all data from one table, while another table is empty and where clause is also applied 将数据从一个表复制到另一个表,但是添加第二个WHERE子句不会插入数据 - Copy data from one table to another but adding 2nd WHERE clause won't insert data 在PHP中将数据从一台服务器传输到另一台服务器 - Transferring data from one server to another in php 使用另一个表上的WHERE子句从表中选择的SQL查询 - SQL Query to select from a table using a WHERE clause on another table 使用另一个表中的字段引用一个 MySQL 表中的数据 - Reference data from one MySQL table by using a field from another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM