Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 22nd, 2004, 05:03 PM
code.commander code.commander is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 25 code.commander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 41 sec
Reputation Power: 0
Query Question

Hello,

I have 3 tables as followed:

Person
-------
ID
Name

GroupPerson
------------
ID
GroupId
PersonId

Group
------
ID
GroupName

I want to find all of the Group items that have a groupName like '%b%' and that has a Person with a name like '%g%' and I want to be able to display the name of the group and the person.

Does anyone know how to do this?

Reply With Quote
  #2  
Old September 23rd, 2004, 01:42 AM
Ankur Gupta Ankur Gupta is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 5 Ankur Gupta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I don't know how you have defined relationship between the tables.
i assumed that
id in person is same as personid in groupperson,
id in group is same as groupid in person.

the query is

select g.groupname,p.name from
person p, groupperson r, Group g
where
p.id=r.personid and
g.id=r.groupid and
g.groupname like '%b%' and p.name like '%g%';

Reply With Quote
  #3  
Old September 23rd, 2004, 10:05 AM
code.commander code.commander is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 25 code.commander User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 41 sec
Reputation Power: 0
Quote:
Originally Posted by Ankur Gupta
I don't know how you have defined relationship between the tables.
i assumed that
id in person is same as personid in groupperson,
id in group is same as groupid in person.

the query is

select g.groupname,p.name from
person p, groupperson r, Group g
where
p.id=r.personid and
g.id=r.groupid and
g.groupname like '%b%' and p.name like '%g%';



Thank you very much. I forgot to make one of the links between the tables. That was why I was getting way too many results. Thanks again.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Query Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT