SQL if语句怎么用

2024-11-27 03:40:33
推荐回答(3个)
回答1:

if是条件分支语句,
IF
语句1
语句2
还可与ELSE 合用
具体的HI 我

回答2:

declare @i int
set @i=datepart(hh,getdate())
if @i<12
print '上午'
else
print '下午'

回答3:

IF @cost <= @compareprice
BEGIN
PRINT 'These products can be purchased for less than
$'+RTRIM(CAST(@compareprice AS varchar(20)))+'.'
END
ELSE
PRINT 'The prices for all products in this category exceed
$'+ RTRIM(CAST(@compareprice AS varchar(20)))+'.'