If I have a table named USER and I have 3 columns user_name
, user_password
and user_surname
, with user_name
and user_password
set as the primary key. When a user log into the program they are required to enter there name and password.
如果我有一个名为USER的表,并且我有3列user_name,user_password和user_surname,并将user_name和user_password设置为主键。当用户登录该程序时,他们需要输入名称和密码。
Now I need to verify this combination, so I need to know if I can do pair-wise comparison like the following:
现在我需要验证这个组合,所以我需要知道我是否可以进行成对比较,如下所示:
SELECT *
FROM user
WHERE (user_name, user_password) = ('&name', '&password');
I know that you can use pair-wise comparison like the above with a IN but do not know if you can use it with =. The thing is that the user needs to enter the two values (name, password) and then it needed to be checked in the table.
我知道你可以像上面的IN一样使用成对比较,但不知道你是否可以使用=。问题是用户需要输入两个值(名称,密码),然后需要在表中检查它。
Please I need advice
我需要建议
4 个解决方案
#1
0
In T-Sql, we use
在T-Sql中,我们使用
Select *
From User
Where User_Name = @Uname AND Password = @Passwd
Your sort of comparison is not possible , I think.
我想,你的比较是不可能的。
Since you are using Access
由于您使用Access
Select *
From User
Where User_Name = ? AND Password = ?
#2
2
Why not just:
为什么不呢:
SELECT *
FROM user
WHERE user_name = '&name'
AND user_password = '&password';
#3
0
Try it with your database, if it does not work just use
尝试使用您的数据库,如果它不起作用只是使用
SELECT * FROM user WHERE user_name = '&name' AND user_password = '&password'
#4
0
SELECT * FROM user WHERE user_name = '&name' AND user_password = '&password'=;
#1
0
In T-Sql, we use
在T-Sql中,我们使用
Select *
From User
Where User_Name = @Uname AND Password = @Passwd
Your sort of comparison is not possible , I think.
我想,你的比较是不可能的。
Since you are using Access
由于您使用Access
Select *
From User
Where User_Name = ? AND Password = ?
#2
2
Why not just:
为什么不呢:
SELECT *
FROM user
WHERE user_name = '&name'
AND user_password = '&password';
#3
0
Try it with your database, if it does not work just use
尝试使用您的数据库,如果它不起作用只是使用
SELECT * FROM user WHERE user_name = '&name' AND user_password = '&password'
#4
0
SELECT * FROM user WHERE user_name = '&name' AND user_password = '&password'=;