Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2007, 11:14 AM
Registered User
 
Join Date: May 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Preventing repetition with Distinct?

Whenever I add a table in my query designer and checkmark Links it causes the guest names to be repeated. If I don't do this the query result is correct. So how do I prevent name repetition but yet add links to the display?

Current Code:

SELECT DISTINCT GuestName, GuestDescription FROM T_ProgramGuests WHERE (ProgramID = 9734)

Link Added to Code:

SELECT DISTINCT T_ProgramGuests.GuestName, T_ProgramGuests.GuestDescription, T_ProgramLinks.URL
FROM T_ProgramGuests CROSS JOIN T_ProgramLinks WHERE (T_ProgramGuests.ProgramID = 9734)

Even if I use a Left Outer Join I get the same.
 
Old May 28th, 2007, 05:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

What is the Column with which you are making the join between T_ProgramGuests and T_ProgramLinks tables? How about posting the structure of the tables here?

_________________________
- Vijay G
Strive for Perfection
 
Old May 29th, 2007, 11:47 AM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To only get one record, make sure that there is only one record in your T_ProgramLinks table. If there are multiple records in that table which have different URL values, then you have to put a JOIN condition or a WHERE clause that will return just 1 URL value.

SQL Server Helper
How well do you know SQL? Find out with the free test assessment from SQL Server Helper!!!
http://www.sql-server-helper.com/free-test/default.aspx

Got a SQL Server Question? Ask us here: http://www.sql-server-helper.com/forums/default.asp





Similar Threads
Thread Thread Starter Forum Replies Last Post
Combobox shows me repetition of entries... sat_u2 VB.NET 2002/2003 Basics 4 January 14th, 2008 02:51 PM
Help!!::XSLT Transformation to remove repetition i techno_savvy81 XML 0 September 19th, 2007 05:01 AM
Preventing Hotlinking simtrade Classic ASP Professional 0 October 14th, 2005 05:06 PM
Distinct SELECT DISTINCT question... EndEffect Classic ASP Databases 4 August 18th, 2005 08:53 AM
Data report dont'want repetition haahoou VB Databases Basics 3 January 25th, 2004 05:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.