A simple solution :

<cfquery...>
SELECT
        'Product' as TableName,
        Title,
        Keywords
FROM
        Product
WHERE
        Keywords LIKE ...

UNION

SELECT
        'Content' as TableName,
        Title,
        Keywords
FROM
        Content
WHERE
        Keywords LIKE ...

UNION

SELECT
        'Departments' as TableName,
        Title,
        Keywords
FROM
        Departments
WHERE
        Keywords LIKE ...
</cfquery>


Ben
http://www.benorama.com

-----Message d'origine-----
De : Paul Giesenhagen [mailto:[EMAIL PROTECTED]]
Envoy� : samedi 10 ao�t 2002 04:33
� : CF-Talk
Objet : Query + Output


I have a situation that I am sure someone will be able to answer.

I have three tables: Product, Content, Departments

They are basically the same (except for a few obvious differences).

I am wanting to do a keyword search on all of them and I need to know where
my result is coming from.

I want to search on the following fields.

title, keywords, content

I could put together a union, but the tricky part (maybe it's not) ... is
that I need to know what table the result is from.  Is it a department,
content or product.

Result set would look something like this:

Title, this is a product
Title1, this is content
Title2, this is a product
Title3, this is a department
Title4, this is content
..

Is this possible in SQL, if not, does anyone have suggestions as to the best
way to do it in SQL/CF?

I would like to avoid running three different queries, but that is an
option.

Thanks!
Paul Giesenhagen
QuillDesign




______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to