Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > Visual Web Developer 2008
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Web Developer 2008 Discuss creating ASP.NET 3.5 sites with Microsoft's Visual Web Developer 2008. If your question is more specific to a piece of code than the Visual tool, see the ASP.NET 3.5 forums instead. If your question is specific to the "Express Edition" be sure to state that in your post.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Web Developer 2008 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old June 6th, 2011, 01:11 PM
Authorized User
Points: 94, Level: 1
Points: 94, Level: 1 Points: 94, Level: 1 Points: 94, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2010
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Join Command - Merge 2 Columns


Not sure if I've posted this one in the correct topic, so feel free to move it. Anyway, here goes.

I am building a music website where I want to display albums. I have built a database that works fine, but I have a problem with the SQL command.

In my database I have a table called DBProducer, with the two columns ProducerID and ProducerName. I have inserted two values this far (see list below). I am using the following SQL command.

SELECT DBAlbum.AlbumName, DBArtist.ArtistName, DBLabel.LabelName, DBGenre.GenreName, DBProducer.ProducerName, DBGrade.Grade


WHERE (DBAlbum.AlbumID = 1) AND (DBGrade.GradeID = 5)
With this I display the following:

AlbumName  ArtistName  LabelName  GenreName  ProducerName  Grade
Album 1    Artist 1    Label 1    Punk       John          5
Album 1    Artist 1    Label 1    Punk       Adam          5
On my website I have a DataList that displays this. By adding "(DBProducer.ProducerID = 1)" to the WHERE command, I only display the first line (John). If I don't add this, the site displays all the information twice, with John as producer in the first set and Adam as the producer in the second. What I want to do is the DataList to display both John and Adam together in one set, and not display the same information twice with different producers, so that in my aspx file the code should look something like this:

<asp:Label ID="ProducerNameLabel" runat="server" Text='<%# Eval("ProducerName") %>' />
<asp:Label ID="ProducerNameLabel" runat="server" Text='<%# Eval("ProducerName") %>' />
(The first label shall display the name John and the second label shall display the name Adam)

How do I do that? I suppose I need a JOIN command but I can't figure it out.

Help would be much appreciated!

Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
T-SQL MERGE and OPENQUERY 4thhorseman SQL Server 2008 1 December 3rd, 2009 08:42 AM
Merge Command uma_10_5 Oracle 3 January 11th, 2006 01:37 AM
Merge/Append Columns calamillo Access 3 November 30th, 2005 03:51 PM
SQL Join mattastic SQL Server 2000 9 April 21st, 2005 10:27 AM
Outer Join, 2 columns jking SQL Language 1 December 5th, 2004 03:14 AM

All times are GMT -4. The time now is 08:42 AM.

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.