Re: Problem with selecting all col of one table in a join
Posted in 1997
Matt Townsend (mtownsend@nlight.com) wrote: : xtcpl wrote: : > SELECT s.* : > FROM strcustr s, appoehdr a : > WHERE (s.cust_code = a.cust_code AND a.order_no=3453) OR : > (s.cust_code = a.cust_code AND a.order_no=3455); : It's use is OK as long as each column name is unambiguous. That can't : happen in a join since (using your example) it can't tell which : cust_code to use, from table a or s. So you say SELECT s.cust_code, : ....,etc. Yes, it can, because it's qualified by the s. SELECT s.* will return only s.cust_code and all the other s columns. : p.s. You might expect poor performance with that OR statement BTW. Good point. And it is easily re-written: SELECT s.* FROM strcustr s, appoehdr a WHERE s.cust_code = a.cust_code AND (a.order_no=3453 OR a.order_no=3455); or what I believe will work even better: SELECT s.* FROM strcustr s, appoehdr a WHERE s.cust_code = a.cust_code AND a.order_no=3453 UNION SELECT s.* FROM strcustr s, appoehdr a WHERE s.cust_code = a.cust_code AND a.order_no=3455; June ---- June Tong Informix Software ---- ---- Senior Consultant (415) 926-6140 ---- ---- International Support junet@informix.com ---- ---- Location-du-jour: ? (can't let Billy Wheeler know) ---- * * Standard disclaimers apply * - Please do not send me requests/questions by mail. When I have the knowledge - and time permits, I try to answer questions on comp.databases.informix, but - travel schedule, time, and volume make responding to personal requests - difficult and often slow. Please call your local Informix Technical Support - organization for assistance with technical issues.