作者:小菜刀丶 | 来源:互联网 | 2023-05-17 16:57
Given a database field named "widget_ids", containing data like "67/797/124/" or "45/", where the numbers are slash separated widget_ids... how would you make an update statement with SQL that would say: "if the widget_ids of the row with id X contains the text "somenumber/" do nothing, otherwise append "somenumber/" to it's current value"
给定一个名为“widget_ids”的数据库字段,其中包含“67/797 / 124 /”或“45 /”之类的数据,其中数字是斜杠分隔的widget_ids ...如何使用SQL创建更新语句:如果id为X的行的widget_ids包含文本“somenumber /”则不执行任何操作,否则将“somenumber /”附加到其当前值“
Can you do something like that with SQL, or more specifically, sqlite? Is that something that is better done in the program for some reason or is there support for "if-then" like syntax in SQL?
你可以用SQL,或者更具体地说,sqlite做类似的事情吗?这是因为某种原因在程序中做得更好还是支持SQL中的“if-then”语法?
2 个解决方案