Hi Matthew,

There are several combination of things you can query for with the data you
have: Only Products with Tags, Only Tags with products, all Products with
or without Tags, all Tags with or without Products....

However you do not have the ability (yet) to query, in a single statement,
for all Products and all Tags (having data all across where they match-up
and having nulls in the columns where they don't until the query engine
supports the FULL OUTER JOIN clause.

Now, there IS a work-around using a LEFT JOIN  UNIONed to a RIGHT JOIN but
I don't know what version of MySQL you have. You may have to use a
different workaround that requires a temporary table.

Can you give us an example of the columns you want to have in your report?

Respectfully,
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine



                                                                                       
                                   
                      Matthew Shalorne                                                 
                                   
                      <[EMAIL PROTECTED]        To:       [EMAIL PROTECTED]            
                                
                      co.uk>                   cc:                                     
                                   
                                               Fax to:                                 
                                   
                      06/01/2004 04:33         Subject:  Left outer join combined with 
inner join                         
                      PM                                                               
                                   
                                                                                       
                                   
                                                                                       
                                   




Hi,
with the tables eg:

Product: id, product, cost

ProductTag: productId, TagId

Tag: id, tag

I have created the ability to selectively assign tags to products if
required via a many-to-many relationship.
Now I want to join the tables in MySQL so that I can see all products
and in the tag column they should have a tag if there is one. I can do
the left outer join to join the product and many-to-many table ProductTag:

select Product.id, ProductTag.TagId from Product left join ProductTag on
Product.id = ProductTag.productId

but how do I then, in the same, select statement describe the join
between ProductTag and Tag to produce the columns:

Product.product, Product.cost, Tag.tag

where most Tag.tag fields will not have values.

I would hugely appreciate any assistance in this regard.
Matthew



--
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