[英]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.