473,549 Members | 2,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"select statement cannot compare one data with multiple data"

68 New Member
Hello!I am using following sql statement:
SELECT Menu.MenuID,Men u.TextUrl FROM Menu WHERE
Menu.MenuID= (SELECT Permissions.Men uID FROM Permissions WHERE
Permissions.Rol eID=(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 1717
amitpatel66
2,367 Recognized Expert Top Contributor
Hello!I am using following sql statement:
SELECT Menu.MenuID,Men u.TextUrl FROM Menu WHERE
Menu.MenuID= (SELECT Permissions.Men uID FROM Permissions WHERE
Permissions.Rol eID=(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
sangam56
68 New Member
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 Recognized Expert Top Contributor
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
2880
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)) { $hasSubmittedUser = 0; $errorMsg .= $font . '<font color=cc0000><li>Could not insert record into db</li></font>' . '</font><p>';
6
7708
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 when CH1 and CH2 have been choosen. $_GET gives me "CH2". Is there any way to get all the choosen channels elements? I would be very appreciative...
3
4684
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 my databases by copying the data folder to some place? Then if I meet some disaster, could I just copy the backup folder back to recover my...
10
5591
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 create a single View and specify also in this View the WHERE clause that is common in these stored procedures, I will have the new stored procecures...
1
2380
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 value from the form and store them as variables which are passed onto another asp page. I then have an SQL statement constructed which takes these...
2
3029
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 be associated with multiple categories. I have an "Issue," "IssueCategory," and "Category" in the database (among other tables). The form has a...
2
4094
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 definition: Column | Type | Modifiers...
3
3078
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 =server.createobject("ADODB.connection") objConn.open "DSN=Photo" Dim sqlSELsite,ObjRSSel sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
7
2909
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 it shows error page not found on this server i googled and found some people use union and select to hack sites (mysql injection) i guess the...
0
7526
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7457
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7965
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7483
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7817
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5092
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3487
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
771
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.