faqts : Computers : Programming : Languages : PHP : Database Backed Sites : Oracle

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 1 people (100%) answered Yes
Recently 1 of 1 people (100%) answered Yes

Entry

How can I search two tables?

Mar 14th, 2005 23:19
Jos Juffermans, Joyce Lam,


This is more an Oracle SQL question.

You can search two tables using a UNION, eg:

SELECT
   firstname AS a_name
FROM
   table1
WHERE
   company='foo'
UNION ALL
SELECT
   alias AS a_name
FROM
   table2
WHERE
   anotherfield='bar'

Would create a recordset with 1 column "a_name" which is a combination 
of table1.firstname and table2.alias (provided the match the WHERE 
clause).