我想从三个表中获取数据:role
、permission
和right
。我使用了内连接。
代码
SqlConnection con = Class3 .GetConnection();
public DataSet showoption1()
{
string sql1 = "select right.rightname,role.rolename
FROM permission
INNER JOIN ON right.rightid = permission.rightid
INNER JOIN role ON permission.roleid = role.roleid ";
SqlCommand cmd = new SqlCommand(sql1, con);
SqlDataAdapter adptr = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adptr.Fill(ds);
DataTable table = ds.Tables[0];
return ds;
}
数据库表
角色
Role Id Role name
1 admin
2 employee
正确的
rifgtid rightname
1 view courses
2 view assessmenttest
权限(关联)
permissionid rightid roleid
1 1 2
2 1 1