Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql “订购”;“乘法”;在代码点火器查询生成器中_Mysql_Sql_Codeigniter - Fatal编程技术网

Mysql “订购”;“乘法”;在代码点火器查询生成器中

Mysql “订购”;“乘法”;在代码点火器查询生成器中,mysql,sql,codeigniter,Mysql,Sql,Codeigniter,我的数据库中有以下表格 Product(product_id,title,sale_price,tax_id) Tax(Tax_id,label,rate) 我正试图显示按产品.销售价格*税率订购的产品列表 我如何使用代码点火器实现这一点 目前,我的代码如下所示: $this->db->order_by('sale_price', 'asc'); $this->db->get('product'); 我曾尝试在SQL中执行类似的操作,但没有成功 SELECT * F

我的数据库中有以下表格

Product(product_id,title,sale_price,tax_id)

Tax(Tax_id,label,rate)
我正试图显示按产品.销售价格*税率订购的产品列表

我如何使用代码点火器实现这一点

目前,我的代码如下所示:

$this->db->order_by('sale_price', 'asc');
$this->db->get('product');
我曾尝试在SQL中执行类似的操作,但没有成功

SELECT * FROM product inner join tax on product.tax_id = tax.tax_id ORDER BY (product.sale_price*tax.rate) ASC
谢谢。

请尝试下面的查询

$this->db->select('*');
$this->db->select('p.sale_price*t.rate as sortable_column');
$this->db->order_by('sortable_column', 'asc');
$this->db->join('tax t', 't.tax_id = p.tax_id');
$this->db->get('product p')->result_array();
尝试下面的查询

$this->db->select('*');
$this->db->select('p.sale_price*t.rate as sortable_column');
$this->db->order_by('sortable_column', 'asc');
$this->db->join('tax t', 't.tax_id = p.tax_id');
$this->db->get('product p')->result_array();

类似于选择销售价格*费率作为“总计”订单,或类似于选择销售价格*费率作为“总计”订单,或类似于选择销售价格*费率作为“总计”订单,或类似于选择销售价格*费率,或类似于选择销售价格*费率作为“总计”订单,或类似于选择销售价格*费率,或类似于选择销售价格*费率,或类似于选择销售价格*费率,或类似于选择销售价格*费率,或类似于选择销售价格*费率,或类似于选择销售价格*费率,或选择销售价格*费率,或选择销售价格*。复制已回答的查询并立即检查。以下消息是由于缺少“sql quotes”因为生成的查询类似于:
'p.sale\u price*t.rate'
但应该是
p`.`sale\u price`*`t`.`rate
我得到了以下错误:
未知列'product.sale\u price*tax.rate'in'字段列表
给出您的表结构。我在下面写了它,我已经更新了答案。复制已回答的查询并立即检查。以下消息是由于缺少“sql quotes”,因为生成的查询类似于:
'p.sale\u price*t.rate'
,但应为
p`.`sale\u price`*`t`.`rate