我有一个mysql查询
timeout = setTimeout(2000,funciton(){
//after 2sec starts
$(this).attr("data-price",dInput);
shoppingCart.setPriceForItem(dInput,id);
displayCart();
//after 2sec ends
});
可以看出,它只允许那些具有$query = "SELECT id,link, shape, size, color, clarity, cut, price, markup, cert, certificateNumber, stockNumber FROM diamonds WHERE cert IN ('GIA,AGS') AND storeKey = '$storeKey' AND size BETWEEN $minCarat AND $maxCarat AND price BETWEEN $minPrice AND $maxPrice AND cut IN($cut) AND clarity IN ($clarity) AND color IN ($color) AND shape IN ($shape) ORDER BY price ASC";
我想添加另一个条件。该表有一列"链接"它可以是空的也可以是非空的。如果我使用GIA或AGS,许多钻石将被排除在外,这些钻石的链接不是空的。我也想为链接添加条件。像
这样的东西cert Either GIA Or AGS
除了AND和其他值之外,我如何添加或
答案 0 :(得分:0)
$query = "SELECT
id,link,shape,size,
color, clarity, cut, price,
markup, cert, certificateNumber,stockNumber
FROM
diamonds
WHERE
(cert IN ('GIA,AGS') or link != '')
AND storeKey = '$storeKey'
AND size BETWEEN $minCarat AND $maxCarat
AND price BETWEEN $minPrice AND $maxPrice
AND cut IN($cut)
AND clarity IN ($clarity)
AND color IN ($color)
AND shape IN ($shape)
ORDER BY price";
仅添加OR
声明