douzhiling3166 2016-10-02 15:03 采纳率: 100%
浏览 27
已采纳

PHP和Mysql || '或'语法?

In mysql I have something like:

$currentname = mysql_query("SELECT * FROM posts LIMIT $start, 5 WHERE ");   

How can i do something like this below that works:

$currentname = mysql_query("SELECT * FROM posts LIMIT $start, 5 WHERE `title` LIKE '%{Hello world}%' || Where `text` LIKE '%{Hello World}%'");

Something like above that will actually work.

  • 写回答

3条回答 默认 最新

  • dsfds656545 2016-10-02 15:06
    关注

    Try this:

    $queryResult = mysql_query("SELECT * FROM posts WHERE `title` LIKE '%{Hello world}%' OR `text` LIKE '%{Hello World}% LIMIT $start, 5'");
    $currentName = mysql_fetch_assoc($queryResult);
    

    if you expect many results...

       while($currentName = mysql_fetch_assoc($queryResult)) {
         //your code here...
       }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?