有关sql语句中的符号问题?把我给弄晕了?

来源:百度知道 编辑:UC知道 时间:2024/05/21 06:12:09
string cmdtext="select realname,role_name,role_description from staff"+"inner join staffrole on staff.staff_id=staffrole.staff_id"+"where staff_name="+'""+susername+""';
这条sql语句里面这么多'""+组合在一起 完全不明白,谁能帮我解释一下,帮忙理一下,谢谢!!

string cmdtext="select realname,role_name,role_description from staff"+"这个地方的+号是字符串连接用的,所以你的这段代码肯定是换行显示的。。staff.staff_id=staffrole.staff_id"+"这里的”+“同上
""+susername+""这里的+“”表示变量引用。
你整个SQL文写成一行的话该是这样:string cmdtext="select realname,role_name,role_description from staff inner join staffrole on staff.staff_id=staffrole.staff_id where staff_name="+susername+"";

select realname,role_name,role_description
from staff inner join staffrole
on staff.staff_id=staffrole.staff_id
where staff_name=susername

从 staff 表 连接 staffrole表,找出staff_id相等的记录。
查出的字段有:realname,role_name,role_description

在PHP里面 '""+susername+""'是会被看作是一个字符串了,不知道其他语言会怎样处理,