取某个字段值,加以判断

MySql help-doc 10年前 (2014-04-27) 1060次浏览 0个评论

table1
id    man          tid
1     first            3
2     second     0
3    three          2

CREATE PROCEDURE dbo.GetNameById
    @id    int,
    @result nvarchar(50) output
AS
select man , @tid =  tid from students where id =@id
    if  @tid = 0 or @tid is null
       set @result = “”当前名字为空!””
如何取到 @tid  字段的值,并加以判断

@tid :=  tid
5分
在非SET语句中=被视为一个比较 操作符:
谢谢您,不行啊,语法错误
错误代码: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near “”:= 
5分
select man,tid as @tid from students where id =@id
 if  @tid = 0 or @tid is null
       set @result = “”当前名字为空!””
10分
select tid into @tid from students where id =@id

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明取某个字段值,加以判断
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!