简体   繁体   English

MYSQL-更新查询的表列结果

[英]MYSQL - update a table column result of a query

I have a table in my database which three columns of data: 我的数据库中有一个表,其中包含三列数据:

1) The clubname;
2) The teamname;
3) The pouleid;

All clubs have more than 1 team. 所有俱乐部都有1个以上的团队。 Each team has 2 pouleid's (an indoor and an outdoor id). 每个团队都有2个Pouleid(室内和室外ID)。

I want to loop through the combination of club-team and find the corresponding pouleid's. 我想遍历俱乐部团队的组合并找到相应的Pouleid。 Then I want to set the lower pouleid to "outdoor" and the higher pouleid to "indoor" in another column of this table. 然后,我想在此表的另一列中将较低的pouleid设置为“ outdoor”,将较高的pouleid设置为“ indoor”。

I can find the results from a specific club/team-combination with a query LIKE 我可以通过查询LIKE从特定俱乐部/团队组合中找到结果

Indoor: 室内:

"SELECT pouleid FROM Stand WHERE clubnaam = 'ZKC' AND clubteam = 'A1' LIMIT 0,1"

Outdoor: 户外:

"SELECT pouleid FROM Stand WHERE clubnaam = 'ZKC' AND clubteam = 'A1' LIMIT 1,1"

But how can I loop through the whole table and find the matching club/team-combination and than update the column with indoor or outdoor? 但是,我如何遍历整个桌子并找到匹配的俱乐部/团队组合,然后用室内或室外更新该列呢? Is that possible in MySql? 在MySql中有可能吗?

I am not 100% sure but I dont think you can solve this only by using SQL... You can easily do this by using any programing language like php or asp. 我不确定100%,但是我不认为您只能通过使用SQL来解决此问题。您可以使用任何编程语言(如php或asp)轻松地做到这一点。 Get all Unique values, and use them one at a time to solve your problem. 获取所有唯一值,然后一次使用它们来解决您的问题。

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

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