比如有表Table1中一个字段 
Field1
'abc<meta name="a" content="123/>def'
'abc<meta name="b" content="123/>def'
'abc<meta http-equiv="refresh" url=abc.com">def'
'sdfsdfd'
...如果Field1字段值中匹配有"<meta"字符串,且meta中有'url'字符串从字段值中删除如上所示,我要的结果是删除'abc<meta http-equiv="refresh" url=abc.com">def' 这条记录中的<meta http-equiv="refresh" url=abc.com">

解决方案 »

  1.   

    mysql不支持 正则删除,用字符串函数解决
      

  2.   

    字符串函数搞不定,难道要拉到前台来用php、.net处理一遍在重写进去?
      

  3.   

    MYSQL中没有 reg_replace, 只能通过一些字符串函数进行简单处理。如果包括多个匹配项,则建议通过程序来解决。mysql> select * from table1;
    +------------------------------------------------+
    | f                                              |
    +------------------------------------------------+
    | abc<meta name="a" content="123/>def            |
    | abc<meta name="b" content="123/>def            |
    | abc<meta http-equiv="refresh" url=abc.com">def |
    | sdfsdfd                                        |
    +------------------------------------------------+
    4 rows in set (0.00 sec)mysql> update table1
        -> set f=concat(mid(f,1,INSTR(f,'<meta')-1),mid(f,LOCATE('>',f,INSTR(f,'<meta'))+1))
        -> where f like '%<meta%url%>%';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from table1;
    +-------------------------------------+
    | f                                   |
    +-------------------------------------+
    | abc<meta name="a" content="123/>def |
    | abc<meta name="b" content="123/>def |
    | abcdef                              |
    | sdfsdfd                             |
    +-------------------------------------+
    4 rows in set (0.00 sec)mysql>
      

  4.   

    update table1
    set field1=concat(susbstring('field1','<',1),substring('field1','>',1))
    where field1 like '%<meta%' and field1 like '%url%'
      

  5.   

    ---通过字符串函数解决
    UPDATE table1
    SET f=CONCAT(MID(f,1,INSTR(f,'<meta')-1),MID(f,LOCATE('>',f,INSTR(f,'<meta'))+1))
    WHERE  f LIKE '%<meta%url%>%';
      

  6.   

    谢大家了,没办法,用.net做了一个程序解决了,哎,费劲