UPDATE 字段中包含逗号 (,) 的 MySQL 表
导入 MySQL 表的是包含用户生成的字段值的报告。
可能的字段值包括:
- PREFIX,1234
- PREFIX1234
- PREFIX_1234
所有示例值都表示相同的内容,但键入方式不同(我不控制输入系统)。
我想让所有值都使用这种格式:
- PREFIX_1234
我试图对数据库运行这个 PHP 查询来修复逗号值:
$sql = "UPDATE tableA
SET unit_number = replace(unit_number,'FRGN,','FRGN_')
WHERE unit_number like 'FRGN,%'";
但这似乎不起作用。
我是否需要转义查询中的逗号才能使其正常工作?
Imported into a MySQL table is a report that contains a user generated field value.
Possible field values include:
- PREFIX,1234
- PREFIX1234
- PREFIX_1234
All the example values represent the same thing but are typed in differently (I don't control the input system).
I would like to have all the values use this format:
- PREFIX_1234
I was trying to run this PHP query against the database to fix the comma values:
$sql = "UPDATE tableA
SET unit_number = replace(unit_number,'FRGN,','FRGN_')
WHERE unit_number like 'FRGN,%'";
But this doesn't seem to be working.
Do I need to escape the comma in the query in order for it to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
或者
Try this:
or