将代码点火器查询转换为 sql 查询



我对编写SQL查询以连接多个表有点困惑。 我已经在代码点火器中完美地编写了该查询作为 folows

$this->db->select('*');
$this->db->from('subscription_payment'); 
$this->db->join('user', 'user.user_id = subscription_payment.user_id');
$this->db->join('subscription', 'subscription.subscription_id = 
subscription_payment.subscription_id');
$this->db->where('subscription_payment.subscription_payment_id',$sid);
$query = $this->db->get(); 
$result= $query->result_array();

帮助我将其转换为SQL查询

使用

echo $this->db->last_query();

将产生

select * from some_table...

就是这样。下次您可以轻松转换所需的任何查询。

select *
from subscription_payment 
join user
on user.user_id = subscription_payment.user_id
join subscription
on subscription.subscription_id =  subscription_payment.subscription_id
where subscription_payment.subscription_payment_id = $sid
SELECT *
FROM subscription_payment
JOIN user ON user.user_id = subscription_payment.user_id
JOIN subscription ON subscription.subscription_id = subscription_payment.subscription_id
WHERE subscription_payment.subscription_payment_id = $sid 
;

相关内容

  • 没有找到相关文章

最新更新