469,950 Members | 1,456 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

"select statement cannot compare one data with multiple data"

Hello!I am using following sql statement:
SELECT Menu.MenuID,Menu.TextUrl FROM Menu WHERE
Menu.MenuID= (SELECT Permissions.MenuID FROM Permissions WHERE
Permissions.RoleID=(SELECT Roles.RoleID FROM Roles WHERE
Roles.RoleName=@inputRoleName))

I am using three tables: Roles, Permissions, and Menu.
The error reads like: use of =,<,> etc cannot compare with multiple results.
In fact second SELECT statement returns multiple MenuID and I need all the possible row from the first SELECT statement.

Is there any way to write the correct sql statement? Please help me. Thanks.
Nov 25 '07 #1
3 1482
amitpatel66
2,367 Expert 2GB
Hello!I am using following sql statement:
SELECT Menu.MenuID,Menu.TextUrl FROM Menu WHERE
Menu.MenuID= (SELECT Permissions.MenuID FROM Permissions WHERE
Permissions.RoleID=(SELECT Roles.RoleID FROM Roles WHERE
Roles.RoleName=@inputRoleName))

I am using three tables: Roles, Permissions, and Menu.
The error reads like: use of =,<,> etc cannot compare with multiple results.
In fact second SELECT statement returns multiple MenuID and I need all the possible row from the first SELECT statement.

Is there any way to write the correct sql statement? Please help me. Thanks.
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT Menu.MenuID,Menu.TextUrl FROM Menu WHERE
  3. Menu.MenuID IN  (SELECT Permissions.MenuID FROM Permissions WHERE
  4. Permissions.RoleID IN (SELECT Roles.RoleID FROM Roles WHERE 
  5. Roles.RoleName=@inputRoleName))
  6.  
  7.  
Nov 26 '07 #2
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT Menu.MenuID,Menu.TextUrl FROM Menu WHERE
  3. Menu.MenuID IN  (SELECT Permissions.MenuID FROM Permissions WHERE
  4. Permissions.RoleID IN (SELECT Roles.RoleID FROM Roles WHERE 
  5. Roles.RoleName=@inputRoleName))
  6.  
  7.  
Thanks!! It worked well. Thanks again!!
Nov 26 '07 #3
amitpatel66
2,367 Expert 2GB
Thanks!! It worked well. Thanks again!!

You are welcome :)

Amit
Nov 26 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Phil Powell | last post: by
6 posts views Thread by Rolf Wester | last post: by
1 post views Thread by Neil H | last post: by
7 posts views Thread by php_mysql_beginer911 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.