You want a LEFT (OUTER) JOIN, which will return nulls for the columns if no
match on the join expression.
 

-----Original Message-----
From: Paul Nowosielski [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 14, 2006 4:44 PM
To: mysql@lists.mysql.com
Subject: Join help

Dear All,

I'm working on a database that has a lot of inconsistencies. I have a large
query that pulls artist and venue information.

My problem is this: I'm trying to create a data feed that lists artists tour
dates, and the relation venue information corresponding to that tour date.
Unfortunately the data is inconsistent.

For example I have an artist thats on tour at a specific venue. I am
supposed to also give the venue format information but some venues do not
have this relation. Therefore these artist tour dates would not be list in
the query return.

Is there a join method that can ignore the fact that there is no venue
information and just populate the fields as blank?

Here is my query so far:

select DISTINCT (t.td_id),ta.NAME as artist,ta.PKEY as artist_id, hta.NAME
as headliner, DATE_FORMAT(t.td_date, '%b %e %Y') as start_date, tv.ADDR1,
tv.ADDR2, tv.NAME as venue, tv.CITY, tv.STATE, tv.COUNTRY,tv.ID as
venID,ta.WEB as artlink,tv.WEBSITE as venweb,vcp.SIZE as vensize,vtp.TYPE as
ventype, vage.TYPE as venage ,tv.TICKETAGNCY1  as ticket1,tv.TICKETAGNCY2 as
ticket2
from tbl_VENUE_TYPE vtp, tbl_VENUE_CAPACITY vcp, tourdates t, tbl_VENUES tv,
tbl_ARTST ta, artist_tourdate at, tbl_ARTST hta, artist_tourdate
hat,tbl_VENUE_TYPE_XREF tvtx,tbl_VENUE_AGE_XREF vax, tbl_VENUE_AGES vage
where t.td_id = at.td_id and at.artist_id = ta.PKEY and t.venue_id = tv.ID
and
hat.headliner=1 and t.td_id = hat.td_id and hat.artist_id = hta.PKEY and
vcp.VENUE_ID = tv.ID and tv.id =tvtx.VENUE_ID AND  tvtx.TYPE_ID = vtp.PKEY 
and vax.VENUE_ID =tv.ID AND vax.AGE_ID = vage.PKEY   AND 
UNIX_TIMESTAMP(t.td_date) >$time GROUP BY t.td_id

Thanks for the help!

--
Paul Nowosielski


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to