假设我有一个如下所示的数组:
weather = ["sun", "clouds", "rain", "hail", "snow"]
Run Code Online (Sandbox Code Playgroud)
我想查找并显示所有包含字母“s”的字符串。这就是我认为我应该做的...
for(var i = 0; i < weather.length; i++)
{
if(weather[i].indexOf('s') != -1)
{
alert(weather);
}
}
Run Code Online (Sandbox Code Playgroud)
但这只是显示所有天气字符串的次数,与其中包含字母“s”的字符串的次数相同。(只会提示:“晴、云、雨、冰雹、雪”3次)
如何让它只提醒包含字母“s”的具体天气名称?
我很厌倦看到这个错误:
消息102,级别15,状态1,过程sp_reorder_quantity,第16行
' - '附近的语法不正确.
它说明了这一点,因为它在第16行说明:
WHERE products.quantity_in_stock – products.reorder_level < @unit;
Run Code Online (Sandbox Code Playgroud)
它的意思products.quantity_in_stock是:An expression of non-boolean type specified in a context where a condition is expected.
CREATE PROCEDURE sp_reorder_quantity
(
@unit int
)
AS
SELECT
products.product_id,
suppliers.name,
suppliers.address,
suppliers.city,
suppliers.province,
'qty' = products.quantity_in_stock,
products.reorder_level
FROM
suppliers
INNER JOIN
products ON suppliers.supplier_id = products.supplier_id
WHERE
products.quantity_in_stock – products.reorder_level < @unit;
GO
Run Code Online (Sandbox Code Playgroud)