tables
category: category_id, name
product: product_id, category_id, name, price ... (up to dozen fields)
Given $product_id value, I want to select all the fields from prduct PLUS the category's name
I can do
1) 1 query
select product.*, category.name as catergory_name from product, category where product.category_id=category.category_id and product.product_id=$product_id
or
2) 2 queries
first
select * from product where product_id=$product_id;
to get all the values of product, and then after get the $category_id from this query, do the second query
select * from category where cateogry_id=$category_id
to get the category's name.
Say if category only has 1 field, product has dozens fields.
In terms of the performance, and code cleaness, should I always use 1 query like in approach 1), or approach 2) is also perfectly fine too?
Thanks!