Solved

Find records impacted by more than 1 person?

Posted on 2011-09-14
4
325 Views
Last Modified: 2012-05-12
Sorry if the title is vague. I couldn't think of a better way to describe
what I'm trying to do.

I have a table that has the following five fields:

COMMENT_SYS_ID,
ASSET_ID,
WORKER_NAME,
COMMENT_DATE,
COMMENT

I want to know what all ASSET_ID's have comments
from both '%JIM'%' and '%NANCY%'. How to do this easily?
0
Comment
Question by:JustinW
  • 2
4 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 36537096
What database?  This was posted in three different zones.

In Oracle and probably some of the others:

select asset_id from table where comment is not null and worker_name like '%JIM%'
intersect
select asset_id from table where comment is not null and worker_name like '%NANCY%'
0
 
LVL 1

Author Comment

by:JustinW
ID: 36537136
Oracle in this case.
Worked perfect, thanks a tonne!
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 36537147
may not be the most efficient but should be portable to just about any SQL based platform


select asset_id from yourtable
where worker_name like '%JIM%'
and asset_id in (select asset_id from yourtable where worker_name like '%NANCY%')
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36537149
>>Worked perfect, thanks a tonne!

Glad to help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

828 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