[英]Attempt to update one mySQL table with data from two other tables is failing
[英]MySQL Update one table, but use data from two other tables as part of the update
我希望更新数据库中的一个表,数据来自php POST。 (这是一个页面,可以一次对行进行多次编辑,然后立即对其进行全部处理),我想要这样,因此对于每个“行”或“循环”,它都会构建一个查询来更新所有一次行。
我想做的是在查询中,从另外两个表中选择数据。 例如
Posted data:
- Task = "Check current Sponsors"
- User Assigned = "Dan"
- Start Meeting = "Mar 1st"
- Meetings Required = 2
对于分配的用户,我希望它基本上执行以下查询:
SELECT
id
FROMteam
WHEREfullname
'
对于开始会议,我希望它执行以下查询:
SELECT
id
FROMmeetings
WHEREstarttime
= ' “的strtotime( ”3月1“)。”'
-strtotime()从字符串中生成Unix时间戳。
但我希望它为提交的每个“任务”执行此操作。 (它通过javascript排队,并将它们全部发送到同一发布请求中)
有人对如何执行此操作有任何想法吗? 提前致谢
表结构:
任务:
id | startmid | length | task | uid | completed
1 | 2 | 1 | Check Sponsors | 1 | 0
会议:(通过startmid加入)
id | maintask | starttime | endtime
1 | Sponsors | 1330007400 | 1330012800
团队:(由uid加入)
id | fullname | position | class | hidden
1 | Team | All Members | black | 0
2 | Dan S | Team Manager | green | 0
您可以使用以下构造:
UPDATE mytable( col1, col2 )
SELECT col1_val, col2_val
FROM someothertables
WHERE cond1 = cond1;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.