Jump to content

group by


SkyRanger

Recommended Posts

Not sure why I am thinking this is so hard but keep getting an error in my code (Visual Basic)

Situation:

database = xmas
table = songlist
column 1 = title
column 2 = artist

I have 2 dropdown boxes being populated
box 1 is the title
box 2 is the artist

When person choses song in box 1 it populates the artist name in box 2 (this part is working) . The problem I am running in to is I need to group all of the songs that are the same to be listed in box 1 but not group the names in box 2

I have(had) select * from songlist group by  title

Link to comment
Share on other sites

1 hour ago, SkyRanger said:

The problem I am running in to is I need to group all of the songs that are the same to be listed in box 1 but not group the names in box 2

What do you mean by "group"?

The normal way this "I have 2 dropdown boxes being populated" problem goes is that you get a list of all titles and put that in the first one, then get a list of all artists that match the title selected in the first.
Neither have anything to do with grouping.

Link to comment
Share on other sites

If I am understanding the question correctly, the query to populate Box 1 is

SELECT DISTINCT title
FROM xmas
ORDER BY title;

On your page, use an onchange handler to send an AJAX request which sends the title then receives the results of this second query to populate Box 2

SELECT artist
FROM xmas
WHERE title = ?

 

Link to comment
Share on other sites

Thanks Barand. Yeah I don't think I explained that correctly.

table is called songlist with multiple columns but only pulling info from 2 of them .  title = song title and artist = song artist.  I have multiple song titles with the same name.  ie: Jingle Bells sung by different artist.  Right now I have it showing all the songs in the list without grouping them together. So once the person picks on a song title in the first box a list of artists shows in the second box who did that song.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.