用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2700|回复: 0
收起左侧

[数据库] mysql语句用codeigniter实现。。。 请赐教

[复制链接]
发表于 2010-3-26 13:25:02 | 显示全部楼层 |阅读模式
首先,下边的我都不会怎么写,举个例子:
select prod_name,prod_price from products where vend_id in(1002,1003) and prod_price>=10;        
        $this->db->select('prod_name,prod_price');
        $price=array('1002','1003');
        $this->db->where_in('vand_id',$price);
        $this->db->where('prod_price>=',10);
        $query=$this->db->get('products');

要都写成以上形式,高手们,帮个忙,$query = $this->db->query("要执行的 SQL"); 这样的就不要了,除非下边的例子都不能用以上的形式写出

96.create view peoductcustomers as select cust_name,cust_contact from customers,orders,orderitems where customers.cust_id = order.cust_id and orderitems.order_num = orders.order_num;
97.select cust_name,cust_contact from peoductcustomers where peod_id = 'tnt';
98.create view vendorlocations as select concat(rtrim(vend_name),'(',rtrim(vend_country),')') as vendors order by vend_name;
99.select * from vendorlocations;
100.create view custtomeremaillist as select cust_id,cust_name,cust_email form customers where cust_email is not null;
101.select * from custtomeremaillist;
102.create view orderitemsexpanded as select order_num,prod_id,quantity,item_price,quantity*item_price as expanded_price from orderitems;
103.select * from orderitemsexpanded where order_num = 2005;

本版积分规则