It repeats itself!
I wrote the following page to make a many-to-many relationship for a site search I need but when I test it it returns the product names several time.something like this: Product1Product1Product2Product2Product2Product1Product1Product3Product3Product3Product4Product4Product4Product4Product5Product5Product5Product5Product5Product5Product5Product5Product6Product6Product6 the comolete code is below. How can I filter the data that it return only one copy of any product not two! Thanks Benifn cfquery name=test datasource=mydatabase SELECT Companies.CompanyID, Companies.CompanyName, Companies.ManagerName, Companies.SalesManagerName, Companies.CompanyCity, Companies.CompanyAdd, Companies.CompanyDesc, Companies.CompanyRank, Companies_Products.Companies_ProductsID, Companies_Products.CompanyID, Companies_Products.ProductID, Products.ProductID, Products.ProductName, Products.ProductDesc, Products.ProductImage, Products.ProductTypeID FROM Companies AS Companies, Companies_Products AS Companies_Products, Products AS Products WHERE Products.ProductID = Companies_Products.ProductID and Companies.CompanyID = Companies_Products.CompanyID; /cfquery html xmlns=http://www.w3.org/1999/xhtml; body cfoutput query=test#ProductName#/cfoutput /body /html ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:297855 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: It repeats itself!
On Jan 31, 2008 2:30 PM, Ali Majdzadeh [EMAIL PROTECTED] wrote: I wrote the following page to make a many-to-many relationship for a site search I need but when I test it it returns the product names several time.something like this: Product1Product1Product2Product2Product2Product1Product1Product3Product3Product3Product4Product4Product4Product4Product5Product5Product5Product5Product5Product5Product5Product5Product6Product6Product6 the comolete code is below. How can I filter the data that it return only one copy of any product not two! Thanks Benifn cfquery name=test datasource=mydatabase SELECT Companies.CompanyID, Companies.CompanyName, Companies.ManagerName, Companies.SalesManagerName, Companies.CompanyCity, Companies.CompanyAdd, Companies.CompanyDesc, Companies.CompanyRank, Companies_Products.Companies_ProductsID, Companies_Products.CompanyID, Companies_Products.ProductID, Products.ProductID, Products.ProductName, Products.ProductDesc, Products.ProductImage, Products.ProductTypeID FROM Companies AS Companies, Companies_Products AS Companies_Products, Products AS Products WHERE Products.ProductID = Companies_Products.ProductID and Companies.CompanyID = Companies_Products.CompanyID; /cfquery html xmlns=http://www.w3.org/1999/xhtml; body cfoutput query=test#ProductName#/cfoutput /body /html cfoutput#test.ProductName#/cfoutput would work, but i'm guessing you want to display the product name once, and related data beneath it? http://tutorial150.easycfm.com/ -- Evelyn the dog, having undergone further modification pondered the significance of short-person behaviour in pedal depressed, pan-chromatic resonance, and other highly ambient domains. Arf, she said. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:297859 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: It repeats itself!
On Jan 31, 2008 2:30 PM, Ali Majdzadeh [EMAIL PROTECTED] wrote: cfoutput#test.ProductName#/cfoutput would work, but i'm guessing you want to display the product name once, and related data beneath it? http://tutorial150.easycfm.com/ -- Evelyn the dog, having undergone further modification pondered the significance of short-person behaviour in pedal depressed, pan-chromatic resonance, and other highly ambient domains. Arf, she said. Exactly. thanks a lot it works very great. Just a question. Does DISTINCT in SQL does the same thing or not? I know it won't be so great like grouping in CFQUERY but someone told me that I can show data once by using Distinct in SQL. Does it work here too or it is for other situation. THANKS IN ADVANCED AGAIN. the tutorial is great. Benign ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:297864 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: It repeats itself!
On Jan 31, 2008 3:02 PM, Ali Majdzadeh [EMAIL PROTECTED] wrote: On Jan 31, 2008 2:30 PM, Ali Majdzadeh [EMAIL PROTECTED] wrote: cfoutput#test.ProductName#/cfoutput would work, but i'm guessing you want to display the product name once, and related data beneath it? http://tutorial150.easycfm.com/ -- Evelyn the dog, having undergone further modification pondered the significance of short-person behaviour in pedal depressed, pan-chromatic resonance, and other highly ambient domains. Arf, she said. Exactly. thanks a lot it works very great. Just a question. Does DISTINCT in SQL does the same thing or not? I know it won't be so great like grouping in CFQUERY but someone told me that I can show data once by using Distinct in SQL. Does it work here too or it is for other situation. THANKS IN ADVANCED AGAIN. the tutorial is great. Benign DISTINCT does what it sounds like it does. it will return unique records. But even if the productIDs in a set of records are the same... what if the companyIDs are different? every column in the record has to be unique for a DISTINCT query to filter it. If you're grouping the output, then presumably the data 'under' the column on which you're grouping will be different, and therefore not filtered out by adding in a DISTINCT. -- Evelyn the dog, having undergone further modification pondered the significance of short-person behaviour in pedal depressed, pan-chromatic resonance, and other highly ambient domains. Arf, she said. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:297866 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: It repeats itself!
Does DISTINCT in SQL does the same thing or not? I know it won't be so great like grouping in CFQUERY but someone told me that I can show data once by using Distinct in SQL. No, DISTINCT only filters out duplicates from your SELECT. If you select company name and product name, for example, if one company has five products you'll see that company five times, because the combination of values in each record is unique. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Training: Adobe/Google/Paperthin Certified Partners http://training.figleaf.com/ WebManiacs 2008: the ultimate conference for CF/Flex/AIR developers! http://www.webmaniacsconference.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:297867 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4