Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在从另一个表中选择另一行以显示更新位置的同时更新表中的一行_Php_Sql_Select_Sql Update_Where Clause - Fatal编程技术网

Php 在从另一个表中选择另一行以显示更新位置的同时更新表中的一行

Php 在从另一个表中选择另一行以显示更新位置的同时更新表中的一行,php,sql,select,sql-update,where-clause,Php,Sql,Select,Sql Update,Where Clause,我有以下表格: __ Members __ ID(int) auto_increment Email varchar(255) not null __Options__ ID(int) auto_increment FORMATION(int) not null 我需要构建一个SQL请求,在那里我可以更新行Options.Formation=1,其中我的行Options.ID=Members.ID,使用电子邮件来识别选择了哪个用户 有人有线索吗? 我在网上搜索了一下,但什么都不想工作(假设您

我有以下表格:

__ Members __
ID(int) auto_increment
Email varchar(255) not null

__Options__
ID(int) auto_increment
FORMATION(int) not null
我需要构建一个SQL请求,在那里我可以更新行
Options.Formation=1
,其中我的行
Options.ID=Members.ID
,使用
电子邮件来识别选择了哪个用户

有人有线索吗?
我在网上搜索了一下,但什么都不想工作(

假设您在
选项
表中有
成员id
,那么我想您需要:

update options
    set formation = 1
    where member_id in (select m.id from members m where m.email = ?);

如果多个成员可以拥有同一封电子邮件,那么请在
中使用
,而不是
=
假设您在
选项
表中有一个
成员id
,那么我想您需要:

update options
    set formation = 1
    where member_id in (select m.id from members m where m.email = ?);

如果多个成员可以拥有同一封电子邮件,则在
中使用
,而不是使用
=

(1)标记您正在使用的数据库。(2)示例数据和所需结果会有所帮助。(3)在
选项
成员
(1)标记您正在使用的数据库之间没有任何联系。(2)样本数据和期望的结果会有帮助。(3)选项和成员之间没有联系。解决了!非常感谢!我会尽快将你的答复标记为答案!:)解决了!非常感谢你!我会尽快把你的答复标记为答案!:)