Skip navigation links

MySQL Forums :: Newbie :: double join in update?


Advanced Search

Re: double join in update?
Posted by: Peter Brawley ()
Date: June 28, 2012 09:48PM

Is this what you mean?


drop table if exists categories, products;
create table categories( category_id int unsigned primary key, category_name char(8)) engine=innodb;
insert into categories values (1,'food'),(2,'utensils');
create table products( 
  product_id int unsigned primary key, 
  category_id int unsigned, 
  product_name char(8),
  foreign key(category_id) references categories(category_id)
) engine=innodb;
insert into products values(1,1,'jam'),(2,2,'fork'),(3,1,'cereal'),(4,2,'knife');

select concat(c.category_name,':',p.product_name) as 'Category:Product'
from categories c
join products p using(category_id);
+------------------+
| Category:Product |
+------------------+
| food:jam         |
| food:cereal      |
| utensils:fork    |
| utensils:knife   |
+------------------+

Options: ReplyQuote


Subject Written By Posted
double join in update? Yakymenko Serhiy 06/28/2012 04:09PM
Re: double join in update? Peter Brawley 06/28/2012 04:35PM
Re: double join in update? Yakymenko Serhiy 06/28/2012 04:46PM
Re: double join in update? Peter Brawley 06/28/2012 09:48PM
Re: double join in update? Yakymenko Serhiy 06/29/2012 01:09AM
Re: double join in update? Peter Brawley 06/29/2012 06:46AM
Re: double join in update? Yakymenko Serhiy 06/29/2012 01:34PM
Re: double join in update? Rick James 07/01/2012 08:25PM
Re: double join in update? Yakymenko Serhiy 07/04/2012 10:37AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.