Indeed, it allows you to save code when displaying the data. It might be fine for your app.
The only problem with this coding is that the business/data logic and presentation logic are mixed, especially if your SQL query is encapsulated in a CFC. If you want to internationalize your application, it won't possible. This is a pure pattern dilemma... ; ) Benoit -----Message d'origine----- De : Mike Byers [mailto:[EMAIL PROTECTED]] Envoy� : lundi 12 ao�t 2002 15:33 � : CF-Talk Objet : RE: Query + Output When I have done things like this in the past I do similar to what Benoit mentioned initially, but I take it one step further. Instead of putting the Tablename column in with a word like 'Product', etc. I put the whole piece if possible. ie. 'this is a product' as Source UNION 'this is a content' as Source UNION 'this is a department' as Source Then the information is in the query data. Fill in around the above obviously with your query. Hope this helps. Mike -----Original Message----- From: Benoit Hediard [mailto:[EMAIL PROTECTED]] Sent: Saturday, August 10, 2002 8:51 AM To: CF-Talk Subject: RE: Query + Output For the output, you could do something like this : <cfoutput query="qSearch"> <cfswitch expression="#qSearch.TableName#"> <cfcase value="Product"> <cfset Description = "this is a product"> </cfcase> <cfcase value="Content"> <cfset Description = "this is a content"> </cfcase> <cfcase value="Department"> <cfset Description = "this is a department"> </cfcase> </cfswitch> #qSearch.Title#, #Description#<br> </cfoutput> Benoit Hediard http://www.benorama.com -----Message d'origine----- De : Paul Giesenhagen [mailto:[EMAIL PROTECTED]] Envoy� : samedi 10 ao�t 2002 15:15 � : CF-Talk Objet : Re: Query + Output Wouldn't the output be: <cfoutput query="querynam"> #queryname.TableName# </cfoutput> How would you tell between departments and content? Paul Giesenhagen QuillDesign ----- Original Message ----- From: "Benoit Hediard" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Saturday, August 10, 2002 4:07 AM Subject: RE: Query + Output > 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 > > > > > ______________________________________________________________________ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm 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

