Does your database support unions?

select id, name, 'table1' as tablename
from table1
where name like '%#search#%'
union
select id, name, 'table2' as tablename
from table2
where name like '%#search#%'

Not an expert on unions, but if you can get them to work they would solve
your problem.

Dan

-----Original Message-----
From: Katrina Chapman [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 23, 2001 8:09 AM
To: CF-Talk
Subject: Query help


Merry Meet,

I have a query that pulls data from almost identical tables and I need to
know which rows come from which tables.

IE:

SELECT id, name
FROM table1, table2
WHERE table1.name LIKE '%#search#%'
OR table2.name LIKE '%#search#%'

then in the output I need to know which table (1 or 2) each record comes out
of.  Can this be done?  If so how?

Blessed Be,
--Katrina Chapman
http://www.katrinachapman.com
http://www.cfchick.com



The information contained in this message is privileged and confidential.  It is 
intended solely for the use of the named recipient.  If you are not the intended 
recipient, you are hereby notified that any disclosure, copying, distribution, or use 
of the contents of this transmission is strictly prohibited.  If you receive this 
message in error, please notify the sender immediately.  Thank you.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to