General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 5th, 2004, 01:05 PM
amit08_kumar amit08_kumar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 amit08_kumar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
SQL query, selecting common values

Dear friends,
I have a table, say Table_1, which has 3 PK. Say P1, P2, P3. One more column is Id.
The actual table contents are as -

P1 P2 P3 Id
0 0 4 960
0 0 5 1
0 0 5 10
0 0 5 960
0 0 6 10
0 0 7 15033
0 0 8 10
0 0 8 960
0 0 8 92606
0 0 9 10

I can select more than one Id at a time.
I have to select the common rows(while selecting more than one Ids).

eg. Say Id 1 & 10
SELECT distinct Id_Prod_Grupo,Id_Prod_Tipo,Id_Prod_Pres
from CVR_PRODUCTOS_TIENDA
WHERE Id_Cliente in(1,10);
It will return 4 rows, but I want only one row which is common to both Id 1 & 10.
ie. 0 0 5
Can u pls help me out?

Reply With Quote
  #2  
Old April 5th, 2004, 07:55 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I don't exactly understand your table structure...

but would this help?


Code:
SELECT distinct Id_Prod_Grupo,Id_Prod_Tipo,Id_Prod_Pres
from CVR_PRODUCTOS_TIENDA
WHERE Id_Cliente=1
OR Id_Cliente=10;


What exactly do you mean by common rows?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > SQL query, selecting common values


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