我有那些 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));