?
Solved

Operator '<=' facing multi-value data

Posted on 2009-03-30
3
Medium Priority
?
200 Views
Last Modified: 2012-05-06
I have the following code:

select * from Request_History
where
      Stage_No <= (select Stage_No from Work_Flow where Role_ID='7')

The question is: this (select Stage_No from Work_Flow where Role_ID='7') sometimes return more than one value, then what operator other than the '<=' shall I use in this case?
0
Comment
Question by:alfardan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 38

Expert Comment

by:Jim P.
ID: 24025355
Try this:
select * 
from Request_History
where Stage_No IN (select Stage_No 
                   from Work_Flow 
                   where Role_ID='7')

Open in new window

0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 1000 total points
ID: 24025364
Or one of these, depending on the result you want when there's more than one row returned by the subquery:
select * from Request_History
where Stage_No <= (select min(Stage_No) from Work_Flow where Role_ID='7')
 
select * from Request_History
where Stage_No <= (select max(Stage_No) from Work_Flow where Role_ID='7')

Open in new window

0
 
LVL 25

Assisted Solution

by:lwadwell
lwadwell earned 1000 total points
ID: 24025368
Hi alfardan,

perhaps you should do

lwadwell
select * from Request_History
where
      Stage_No <= (select max(Stage_No) from Work_Flow where Role_ID='7')

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question