我有一个非常大的MySQL数据库表(帖子),在一个字段(post_text)中有很多需要修剪的旧BB代码。
这是我需要找到的一个例子:
quote:1270ae936b
(之后:字符变化,总是10)
并替换为:
quote:
我如何在SQL命令中执行此操作?
提前致谢! :)
答案 0 :(得分:0)
未经测试但逻辑上它应该适合您。在http://dev.mysql.com/doc/refman/5.7/en/pattern-matching.html
查看有关特定字符范围的详情测试查询:
len(MyReport.objects.all())
主要查询:
Traceback (most recent call last):
File "C:\Eclipse-SDK-4.2.1-win32-x86_64\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd_comm.py", line 765, in doIt
result = pydevd_vars.evaluateExpression(self.thread_id, self.frame_id, self.expression, self.doExec)
File "C:\Eclipse-SDK-4.2.1-win32-x86_64\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd_vars.py", line 378, in evaluateExpression
sys.stdout.write('%s\n' % (result,))
File "C:\Python27\Lib\site-packages\django\db\models\query.py", line 234, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "C:\Python27\Lib\site-packages\django\db\models\query.py", line 258, in __iter__
self._fetch_all()
File "C:\Python27\Lib\site-packages\django\db\models\query.py", line 1074, in _fetch_all
self._result_cache = list(self.iterator())
File "C:\Python27\Lib\site-packages\django\db\models\query.py", line 75, in __iter__
setattr(obj, attr_name, row[col_pos])
AttributeError: can't set attribute