如何在SQL中的单列中更新多个逗号分离值
SQL上的问题
假设有一个Table Team_info,该列有两个列。一个是team_name,第二个是team_members。因此,在此表中已经存在数据。
team_info
team_name || team_members 战士||约翰
现在,我想在team_members专栏中添加更多的人,例如我需要再添加两个人:Alexa和tony带有John
Expect Tought Output的输出应像
team_info
team_info team_name || 一样。 team_members 战士|| John,Alexa,Tony
我正在使用以下更新查询,但它显示了错误
更新team_info set team_members ='john,alexa,tony'
更新Team_Info SET Team_Members ='John; John; Alexa; Alexa; Tony'
同样,我也使用了很多方法,但无法获得所需的结果。
有人可以帮我吗?
先感谢您。
Question on SQL
Suppose there is a table Team_Info which has two columns. One is Team_Name and 2nd is Team_Members. So in this table already data exists.
Team_Info
Team_Name || Team_Members
Warriors || John
Now I want to add more people in Team_Members columns like I need to add two more people : Alexa and Tony with John
Expected output should be comma seperated like below
Team_Info
Team_Name || Team_Members
Warriors || John,Alexa,Tony
I am using update query like below but it shows error
Update Team_Info set Team_Members='John,Alexa,Tony'
Update Team_Info set Team_Members='John;Alexa;Tony'
Likewise I used so many ways but unable to get desired result.
Could anyone please help me on this ?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法通过提供的信息来重现您的语法错误,因此我怀疑您在某处误入歧途。
但是,请参阅评论 - 这是存储数据的错误方法。也许这些代码片段会有所帮助。
您需要一张桌子来包含团队和一个桌子来包含人员。然后,您需要一个单独的表才能将两者链接在一起。
例如,
要将数据全部报告在一起,从这些加入开始
,您可能需要进行自己的研究:
I can't reproduce your syntax error with the information you have provided so I suspect you have mistyped something somewhere.
However, see the comments - this is the wrong way to store your data. Perhaps these code snippets will help.
You need a table to contain the Team and a table to contain the People. You then need a separate table to link the two together.
E.g.
To get your data all reported together start with these joins
Things you may need to do your own research for: