Networks

Question

Select Distinct with Multiple Columns SQL Server

Hi,I have a SQL Server 2005 database in which 3 tables are joined together by prodid field.Here is a query which gets me close but not quite close enough. In this query the Product Name (from the Products table) shows up 4 times IF there are 4 options related to that Product. May be that's inevitable as far as query is concerned but how can I then show the Product name only once on a page (it is ColdFusion) if there are 4 options while still showing the product only once if there is only 1 option (the default option of 'na' in the Products_options table.Thanks!----------------------------SELECT dbo.products.prodid, dbo.products.name, dbo.products.description, dbo.products.image, dbo.products_options.optionname, dbo.products_options.price, dbo.products_options.optionidFROM dbo.products_featured INNER JOIN dbo.products ON (dbo.products_featured.prodid = dbo.products.prodid) INNER JOIN dbo.products_options ON (dbo.products.prodid = dbo.products_options.prodid)

Thank you.

Thank you, SinisterSlay. I ended up fixing the problem by using a 'group by' in ColdFusion Output for the query and then sub-querying within the output to get the Options for Products. I know, not the most efficient way but the database is small and I needed to move on!

Start or search

Create a new discussion

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

Post type

Subject title

Topic Tags

Select up to 3 tags (1 tag required)

Cloud

Piracy

Security

Apple

Microsoft

IT Employment

Google

Open Source

Mobility

Social Enterprise

Community

Smartphones

Operating Systems

Windows

Mac

Malware

Tablets

Networking

Browser

Hardware

Software

Web Developerment

Linux

Off Topic

Message Body

Track this discussion and email me when there are updates

Please note: Do not post advertisements, offensive material, profanity, or personal attacks. Please remember to be considerate of other members. If you're new to the TechRepublic Forums, please read our TechRepublic Forums FAQ. All submitted content is subject to our Terms Of Use.