简单的查询语句(20分)

  • 主题发起人 主题发起人 ilovellq
  • 开始时间 开始时间
I

ilovellq

Unregistered / Unconfirmed
GUEST, unregistred user!
请问如果我要从一张表中查询密码是否和帐号一致,我该用怎样的语句?<br>例如,create table tel <br>&nbsp;( &nbsp; &nbsp; &nbsp; &nbsp; key serial primary key, &nbsp; &nbsp;<br> telno char(32) default '' 帐号<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;psw &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char(32) default '' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 密码<br>&nbsp;)<br>;
 
select * from tel where telno&lt;&gt;psw
 
检查是否输入了tel 和 psw<br>select psw from tel where telno=<br>if 结果为空 then<br>&nbsp;名字不存在 exit<br>if psw&lt;&gt;输入 then<br>&nbsp;密码不正确<br>正确
 
create procedure p_check_password (<br>&nbsp; @key int,<br>&nbsp; @telno varchar(255),<br>&nbsp; @psw varchar(255),<br>&nbsp; @return_tag bit output &nbsp; --返回值,通过返回值判断密码是否对<br>)<br>declare @pass varchar(255)<br>select @pass = psw from tel where &nbsp;key = @key &nbsp;--如果账号是唯一的也可以用帐号来找如:select @pass = psw from tel where &nbsp;telno = @telno<br>if @pass = @psw <br>&nbsp; set @return_tag = 1<br>else<br>&nbsp; set @return_tag = 0<br>return 0 &nbsp;
 
写完后发现少了这一句<br>少了as <br>不用我说应该中哪里了吧,就在declare @pass varchar(255)上一行<br>
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
871
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部