[ 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
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
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
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php