如何将此php查询转换为mysql?

时间:2019-03-17 04:42:13

标签: php mysql

尝试使用此查询通过mysql获取数据

$this->db->select("ii.id,oi.user_id as uid,oi.id as oid")->from("order_info oi")->join("iform_info ii","oi.id = ii.order_id")->where("oi.order_no",$id)->get()->row_array();

我在想这样的事情

SELECT * FROM `order_info` JOIN(iform_info) WHERE `order_id` = '1'

1 个答案:

答案 0 :(得分:1)

尝试一下:

$this->db->select("ii.id,oi.user_id as uid,oi.id as oid")->from("order_info oi")->join("iform_info ii","oi.id = ii.order_id")->where("oi.order_no",$id)->get()->row_array();

转换为

SELECT ii.id, oi.user_id as uid, oi.id as oid
FROM order_info oi JOIN iform_info ii ON oi.id = ii.order_id 
WHERE oi.order_no = $id

您可以在PHP代码中使用此SELECT查询,并动态传递$id