473,387 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

"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 1712
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

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

Similar topics

3
by: Phil Powell | last post by:
$sql = 'INSERT INTO fs_usermetadata (' . substr(trim($cols), 0, strrpos(trim($cols), ',')) . ') VALUES (' . substr(trim($values), 0, strrpos(trim($values), ',')) . ')'; if (!mysql_query($sql))...
6
by: Rolf Wester | last post by:
Hi, I have a form with a select element with multiple="true". When using the GET method (I suppose the same happens with the POST method) I can seen that the form sends channels=CH1&channels=CH2...
3
by: 21novembre | last post by:
Hi all, I made a question several days before to describe my strange trouble of mysqldump. But I still can't figour it out. Well, I just want to ask another question whether I could just backup...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
1
by: Neil H | last post by:
Hi All I am doing a multiple table and field database search, and my problem lies in the options that a user has. In each field, the user can specify a specific value or any value. I take each...
2
by: google | last post by:
Hello everyone, I am having an issue using the "Multi Select" option in a list box in MS Access 2003. I am making a form that users can fill out to add an issue to the database. Each issue can...
2
by: Florian G. Pflug | last post by:
Hi Since sometime yesterday, my postgresql (7.4.5) reports "ERROR: cannot compare arrays of different element types", when I analyze a specific table in my database. Here is the tables...
3
by: divya | last post by:
Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn...
7
by: php_mysql_beginer911 | last post by:
Hi .. hope someone will help i am trying to figure it out why i cannot post string "union select" every time i try to post data which content union and select .. the page doesn't get posted and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.