Hi dante, all,

[EMAIL PROTECTED] wrote:
[[...]]

In a nutshell, i need a query intelligent enough to make a query to table_Out,
see if theres a match for 'id_tA', if there is one, retrieve field "ref",
otherwise go look in table_In and retrieve "ref" from there.

Is it too complicated (impossible?) to use only one query? Should i just do it
the old style, two queries and a php condition between them?

Well, you need two SELECT statements, but you can combine them in one Query using UNION:

   SELECT ... FROM tableA, table_out WHERE ...
   UNION
   SELECT ... FROM tableA, table_In  WHERE ... ;

I leave the details to you, you should know your conditions best.

Also, it is up to you what to do if one row in tableA can be joined to both of table_out and table_In, or to none of them.


HTH,
Jörg

--
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to