关闭。我在其他与布尔值无关的地方出错了。
我在这个SQL中做错了什么:

WHERE (country = 'HK') OR (country = 'TW') OR (country = 'AX')

输出中缺少AX的结果。
这个布尔表达式有什么问题?
注1.'斧头的末端是我的打字错误。我在上面更正了。
这里有完整的代码
$myresult = mysqli_query($GLOBALS['DBlink'],
    "SELECT $getcolumn
     FROM levermann
     WHERE
        ( $sqlwhere2 ) AND
        levermann.`WEEK` =
            (SELECT `WEEK`, COUNT(*) AS cc
            FROM levermann
            WHERE ( $sqlwhere2 )
            GROUP BY `WEEK`
            HAVING cc > 4
            ORDER BY `WEEK` DESC
            LIMIT 1 )
        AND $lswitch AND $marketcap
    ORDER BY LScore2 DESC, MarketCAPUSD DESC, Stock_Short ASC
    LIMIT 10;");

if  ($region == 'ASIA') {
    $sqlwhere2 = "
        ( country = 'HK' ) OR
        ( country = 'TW' ) OR
        ( country = 'AX' ) OR
        ( country = 'KS' ) OR
        ( country = 'SS' )";
    $region='Asia';
}

if  ($region == 'Global') {
    $sqlwhere2 = " country  like '%'";
    $region='Global';
}

if  ($region == 'US') {
    $sqlwhere2 = " country  = 'US'";
    $region='US';
}

最佳答案

结尾处有一个特殊字符,包含'AX‘
为什么不直接使用in()

WHERE country in ('HK','TW','AX')

关于mysql - SQL中的长 bool 值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50905494/

10-12 15:43