原生的sql写法: SELECT * FROM br_esf_village_building WHERE 1 ORDER BY CONVERT( `buildingName` USING gbk ) COLLATE gbk_chinese_ci ASC tp框架的写法: $data = $this->where($where)->field($field)->order('CONVERT( `buildingName` USING gbk )COLLATE gbk_chinese_c
SELECT * FROM `assets_message` LEFT JOIN purchase_message ON assets_message.purchase_id = purchase_message.purchase_id WHERE `purchase_type` = 'oassets'AND purchase_message.assets_type = '002' ORDER BY purchase_message.purchase_id,assets_id SELECT *
排序查询语法: select 查询字段1from 表where [筛选条件]order by 要排序字段2 asc升序.desc 降序,要排字段3 asc升序.desc降序如果不写默认为升序 案例:查询员工信息,要求工资从高到低排序 SELECT * FROM employees ORDER BY salary DESC; #案例2:查询部门编号>=90,按入职日期升序的员工信息 SELECT * FROM employees WHERE department_id >=90 ORDER BY
#排序查询/*语法:select 查询列表 from 表 [where 筛选条件] order by 排序序列 [asc/desc] */SELECT * FROM employees ORDER BY salary DESC; #默认是asc(升序) #查询部门编号>=90的员工信息,按入职时间的先后排序SELECT * FROM employees WHERE department_id>=90 ORDER BY hiredate ASC; #按年薪的高低显示员工的信息和年薪SELECT