Question about SELECT statement

Reply

Join Date: Jun 2005
Posts: 92
Reputation: michael123 is an unknown quantity at this point 
Solved Threads: 0
michael123 michael123 is offline Offline
Junior Poster in Training

Question about SELECT statement

 
0
  #1
Jul 16th, 2009
I have one table in this format:
Product  Component
---------------------------
A            part1
A            part2
B            part1
B            part4
A            part3
C            part5
D            part1

now I want to display product which components meet requested items, for example:
I know component are "part1" and "part3", need to show product name (that is "A").
How can I do that in SQL statement?

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 123
Reputation: cgyrob is on a distinguished road 
Solved Threads: 18
cgyrob's Avatar
cgyrob cgyrob is offline Offline
Junior Poster

Re: Question about SELECT statement

 
1
  #2
Jul 16th, 2009
  1. SELECT Product FROM Table
  2. WHERE Component IN ('part1','part3')
Last edited by cgyrob; Jul 16th, 2009 at 6:53 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 92
Reputation: michael123 is an unknown quantity at this point 
Solved Threads: 0
michael123 michael123 is offline Offline
Junior Poster in Training

Re: Question about SELECT statement

 
0
  #3
Jul 16th, 2009
How about "part1", "part3" are retrieved from SELECT statement? to use "select from table where component in (select part1 from....)"?
Also "IN(part1, part3)" is OR , not AND, right? I need "AND".
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,464
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 629
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: Question about SELECT statement

 
0
  #4
Jul 16th, 2009
cgyrob's response was what you asked for. What is your real goal here? Or are we not understanding your problem correctly?
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 123
Reputation: cgyrob is on a distinguished road 
Solved Threads: 18
cgyrob's Avatar
cgyrob cgyrob is offline Offline
Junior Poster

Re: Question about SELECT statement

 
0
  #5
Jul 17th, 2009
If you really want an 'AND' use an 'AND'

  1. SELECT Product FROM Table
  2. WHERE Component = 'part1'
  3. AND Component ='part3'
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 405 | Replies: 4
Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC