mysql 数据库中as 和where用法

CREATE TABLE `commoncore` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `CCorder` int(11) default NULL,
  `CCIndex` text,
  `Standard` text,
  `Grade` text,
  `Strand` text,
  `Cluster` text,
  `Standard #` text,
  `Cluster2` text,
  `importData` text,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;这是表结构

select * from commoncore limit 0 , 495 可以查出来表的第一条开始 一共495条数据

 

SELECT Grade  FROM `commoncore` where Grade is not null GROUP BY Grade ORDER BY CAST( Grade AS UNSIGNED ) , Grade查出表grade字段 然后排序 我的gade 是text类型的 查出来的结果是k k12 1,2,3,4,5.。。。。。

 

select com.grade from  (select * from commoncore limit 1,495) as com where com.grade is not null  group by com.grade order by cast(grade as unsigned),com.grade查出来表的前495条数据 并排序

 

posted on 2012-08-20 12:02  爱直至成伤lie  阅读(16483)  评论(0编辑  收藏  举报