Hello to all,
  
  I'm trying to make a query with only one command but I can't see how to do 
  it.
  
  Supose that are 2 tables like:
  
  table QA      table QB
  ref text      ref text
  --- ----      --- ----
  a1 texta1     b1 textb1
  a2 texta2     b2 textb2
  a3 texta3     b3 textb3
  
  and there is a table that indicates the relation between QB and QA data:
  
  table relAB
  A   B
  --  --
  a1  b2  
  a1  b3
  a1  b4
  a2  b1
  a2  b2
  
  This example says that b2,b3,b4 are related to a1 and b1,b2 are 
  related to a2.
  
  What I want to do is get a list from table QB related to an item from 
  table QA:
  
        For example, get a list from QB related to item 'a1':
  
        1. select B from relAB where A='a1';
  
        (result: b2, b3, b4)
  
        2. select * from QB where ref in ('b2','b3','b4');
  
        (result: only 'a1' related items)
  
  There is a way of make this query with only one command?
  
  Something like:
  
        1. select * from QB where ref in (select B from relAB where A='a1');
  
  
  
  Please help me in this matter.
  
  Thanks very much,
  
  
-- 
Nuno Teixeira
pt-quorum.com

/* 
PGP Public Key:
http://www.pt-quorum.com/pgp/nunoteixeira.asc
Key fingerprint:
8C2C B364 D4DC 0C92 56F5  CE6F 8F07 720A 63A0 4FC7
*/

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to