?
Solved

Find matching records

Posted on 2009-04-11
3
Medium Priority
?
281 Views
Last Modified: 2013-12-18
I have a table that stores and OP_ORG_ID, OP_ID and ORG_ID associated with each OP_ID.

An example would be like
OP_ORG_ID, OP_ID, ORG_ID
114, 12345, 10
115, 12345, 40

I want to be able to query the table and find all instances where an OP_ID has both ORG_ID 10 and 40 associated to it
0
Comment
Question by:bhinshawnc1
3 Comments
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 2000 total points
ID: 24122639
Hope this helps you out
SELECT OP_ID
FROM urtable
WHERE ORG_ID IN ( 10, 40) 
GROUP BY OP_ID
HAVING COUNT(ORG_ID) = 2

Open in new window

0
 
LVL 14

Expert Comment

by:ajexpert
ID: 24122659
Your question is not clear.  Do you have multiple tables having OP_ID column?
Can you provide more data and table structures?
0
 
LVL 3

Author Closing Comment

by:bhinshawnc1
ID: 31569198
Thanks, this got me going in the right direction as part of a larger query I was building.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows how to recover a database from a user managed backup
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

864 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