请更正该sql查询.

编程入门 行业动态 更新时间:2024-10-12 03:16:37
本文介绍了请更正该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查询.

本文发布于:2023-11-22 06:08:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616260.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正该   sql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!