使用左连接修复错误

时间:2014-11-28 02:26:22

标签: php mysql

这个命令有什么问题?我收到错误,不知道出了什么问题

    $qrys = mysql_query("
    SELECT *
    FROM users
    LEFT JOIN follows ON follows.followbyid != '$userid' 
    WHERE users.active = 1 AND users.followex = 1 AND users.credits > 0 AND users.twid != '$userid' AND users.twimg != ''
    ORDER BY users.featured DESC, users.buyer DESC, users.retweets DESC 
    LIMIT 49
    ") or die (mysql_error()); 

1 个答案:

答案 0 :(得分:0)

这不应该是:

   $qrys = mysql_query("
    SELECT *
    FROM users
    LEFT JOIN follows ON **[A JOIN CRITERIA]**
    WHERE users.active = 1 AND users.followex = 1 AND users.credits > 0 AND users.twid != '$userid' AND users.twimg != '' **AND follows.followbyid != '$userid'** 
    ORDER BY users.featured DESC, users.buyer DESC, users.retweets DESC 
    LIMIT 49
    ") or die (mysql_error()); 

也停止使用mysql_query并至少使用mysqli。