Re: UPDATE lot of registers

From: Date: Tue, 20 Oct 2009 00:42:49 +0000
Subject: Re: UPDATE lot of registers
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-46585@lists.php.net to get a copy of this message
[ please always send to the mailing list ] Emiliano Boragina wrote:
Hi Chris, thanks for your ask... This doubt was beacause I have two tables... one with categories (category id and category name), and the other with products (product id, product name, category id which the prod belong). The client, sometimes, change the category name. To there no problem using the in the in the products table.
I'm still confused. If you're changing the category name, you only need to change the categories table. update categories set name='new name here' where category_id='X';
But, I must do a finder to search and list the products under category name which it belongs, it name and other items... So the finder is not so easy to do...
To understand this, it'd be easier in two steps to start off with: 1) Get the category_id: select category_id from categories where category_name='XXXXXXXXXX'; 2) Then get the products: select product_id, product_name from products where category_id='X'; That can be combined in to one query: select product_id, product_name from products p inner join categories c on (p.category_id=c.category_id) where c.category_name='XXXXXXXXXX'; Or am I still missing a piece of the puzzle? -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.db (#46585) next »