Jump to content

Recommended Posts

I have 2 tables MusicEvents & Bands: 

 

MusicEvents lists the bands that are playing on a given date at a given venue.

Bands lists the websites and other info about the band.

 

So, I am trying to generate a list of Bands from MusicEvents, that I do not have info yet.  I do this by a Left Join between Music.EventsBand and Bands.Band.  And then asking only for the band name when the BandSite column  (band's website) is Null.  As follows: 

 

SELECT DISTINCT MusicEvents.Band,BandSite FROM MusicEvents LEFT JOIN Bands ON MusicEvents.Band=Bands.Band WHERE BandSite IS NULL ORDER BY MusicEvents.Band ASC;

 

This is kind of working.  It seems that if a band is listed twice in my MusicEvents table, then even if it has a website address in the bands table, it is returned.  I have tried Selecting just MusicEvents.Band as well as using a GROUP BY Band clause which did nothing.  Can anybody please give me a clue as to how to eliminate this redundancy.  Thank you!!!

 

-GR

 

Ok, I urlencoded all of my resutls and found out there was an untrimmed space in front of some of the entries, which accounts for Distinct not sorting theses out.  This is surprising! 

 

When I look through phpmyadmin for these entries.  They do not show up as containing any leading whitespace.  And of course they shouldn't b/c before I insert them into my database, I use php's trim command.  maybe i should trim more spaces before insert?

 

 

 

 

 

 

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.