代码之家  ›  专栏  ›  技术社区  ›  Zack Burt

如何解释mysql文本字段中的换行符?

  •  0
  • Zack Burt  · 技术社区  · 15 年前

    对于“文本”字段中的换行符,正确的语法是什么?例如,

       mysql_query("select * from table where misc_note='hello\nworld'")
    

    不起作用

    3 回复  |  直到 15 年前
        1
  •  1
  •   Imre L    15 年前

    如果你想这样做: char(10) char(13),char(10) \n \r\n

    mysql_query("select * from table where misc_note=concat('hello',char(13),char(10),'world')")
    

    编辑:但是您可能需要:

    mysql_query("select * from table where misc_note like 'searchstring%'")
    

    %表示可能出现的任何字符的任何数目,意味着您要用“searhstring”搜索所有notes startig。

        2
  •  0
  •   knagode    15 年前

    如果\n仍然无法工作,您可以尝试\r\n。

        3
  •  0
  •   Community Mohan Dere    9 年前

    有一个PHP常量, PHP_EOL

    有关详细信息,请访问: When do I use the PHP constant "PHP_EOL"?

    不确定这是否能在你的特定情况下帮到你,但是的,只是把它扔出去。

    推荐文章