我有2张桌子 SjohlLBzads_products & SjohlLBzads_products_meta 按列(post_id)连接为外键。
如何在多个表上创建查询?
我现在拥有的控制器功能只能查询单个表(SjohlLBzads_products)。
我想在SjohlLBzads_products_meta中显示发货列以及当前表中的其他列。
public function index(){
$this->load->library('lib_pagination');
$pg_config['sql'] = "SELECT * from SjohlLBzads_products";
$pg_config['per_page'] = 50;
$data = $this->lib_pagination->create_pagination($pg_config);
$this->load->view("product_listing", $data);
谢谢!
答案 0 :(得分:0)
使用JOIN声明
$pg_config['sql'] = "SELECT * FROM SjohlLBzads_products
JOIN johlLBzads_products_meta
ON johlLBzads_products.post_id = johlLBzads_products_meta.post_id ";