我有那些MySQL表:
products
id
products_content
product_id, lang, product_name, product_content
products_and_categories
product_id, category_id
products_categories
id, parent_id
products_categories_content
category_id, lang, category_name, category_content
products_and_prices
product_id, price_id
products_prices
id
products_prices_content
price_id, lang, description, weight, price, currency
如何选择ID为5的所有产品(例如)以及每种产品的所有价格?是否可以使用单个查询?
目前要选择所有类别的产品,我正在使用(CodeIgniter):
$this->db->select('*')
->from('products')
->join('products_content', 'products_content.product_id = products.id')
->join('products_and_categories', 'products_and_categories.product_id = products.id')
->where(array('category_id' => $category_id, 'lang' => $lang));