MySQL Forums
Forum List  »  Newbie

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

Written By
Re: double join in update?
June 28, 2012 09:48PM
July 01, 2012 08:25PM

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.