[英]How to get same name or id from another table with matching name or id in another table
I am using c# and mysql database 我正在使用c#和mysql数据库
I have 2 tables 我有2张桌子
1st is for info 第一是信息
(Int primary key) (varchar) (int)
Id name year
2015 user1 1
2016 user2 2
2nd is for accounts 第二个是帐户
(Int primary key) (varchar) (varchar)
Id (username) name password
2015 user1 123
2016 user2 123
I want to make query that if I would go to make an account with the same id(username) or name after the login then it will show it in datagrid, but I don't know what query I should use. 我想查询一下,如果我要在登录后创建一个具有相同id(username)或名称的帐户,那么它将在datagrid中显示它,但是我不知道我应该使用什么查询。
That means I want to get a result like this for every account which has the same id or name and not show all the data after the login 这意味着我想为每个具有相同ID或名称的帐户获得这样的结果,并且在登录后不显示所有数据
3rd table showed in datagrid datagrid中显示的第三张表
Id name year
2015 user1 1
When a user does « login » then its id is available to the application. 当用户进行“登录”时,其ID可用于应用程序。 Just pass this id to a simple SELECT query (seems like you don't even need a JOIN) : 只需将此id传递给简单的SELECT查询(似乎您甚至不需要JOIN):
SELECT
tblstudent.StudentID,
tblstudent.Name,
tblstudent.YearLevel
FROM
tblstudent
WHERE tblstudent.StudentID = ?
You want to replace the « ? 您要更换«吗? » with the id of the student that just logged in. »和刚刚登录的学生的ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.