關于mysql if then用法
不知你用的是什么查詢分析器。
我記得 select count(*) into @cnt from table1 where map_id = 114 and `type` = 400 ;if @cnt > 0 then update table1 set `count` = 25 where map_id = 114 and `type` = 400; else insert table1 (map_id,`count`,`type`) values (114,25,400);end if ; 而且好像if then endif只能在procedure或是function里用吧。
關于mysql if then用法
不知你用的是什么查詢分析器。
我記得 select count(*) into @cnt from table1 where map_id = 114 and `type` = 400 ;
if @cnt > 0 then update table1 set `count` = 25 where map_id = 114 and `type` = 400;
else
insert table1 (map_id,`count`,`type`) values (114,25,400);
end if ;
而且好像if then endif只能在procedure或是function里用吧
sql中if then的使用
if 后面沒then
引用sql聯機叢書
IF。ELSE
在執行 Transact-SQL 語句時強加條件。如果條件滿足(布爾表達式返回 TRUE 時),則在 IF 關鍵字及其條件之后執行 Transact-SQL 語句。可選的 ELSE 關鍵字引入備用的 Transact-SQL 語句,當不滿足 IF 條件時(布爾表達式返回 FALSE),就執行這個語句。
語法
IF Boolean_expression
{ sql_statement | statement_block }
[ ELSE
{ sql_statement | statement_block } ]
另外你這個觸發器能執行?
set @q = *view_id
while(*view_id!=MAX(filmreview_id))
這兩行我怎么看都不符合sql語法啊
轉載請注明出處華閱文章網 » mysqlifthen語句