请更正该sql查询. [英] pls correct that sql query.

查看:88
本文介绍了请更正该sql查询.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我分别从users和groups表和
中获取用户名和角色名
我有第三个角色表,该表具有来自users表和groups表的userid和groupid外键.

现在,我想根据用户名和角色名将角色分配给用户(如果它不存在于数据库中).但是首先我要检查角色是否在数据库的角色表中退出.

所以我写了一个查询来实现它.其执行不正确


i am taking username and rolename from users and groups table respectively and

i have a third role table which has a foreign key of userid and groupid from the users table and groups table.

now i want to assing roles to users on the bases of username and rolename if it doesnot exits in the database. but first i am checking that whether the role exits or not in the role table of the database.

so i write a query to implement it. its not executing properly


<pre lang="c#">"SELECT Count(UserId,GroupID) FROM roles Select UserId,GroupID from Users,Groups WHERE username = ''" + TextBox1 + "'' AND name = ''" + TextBox2.Text + "''";



有人可以帮我改正吗.



can anyone help me to correct it out.

推荐答案

尝试
Count(UserID) or Count(*)


这篇关于请更正该sql查询.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆