select * from table where category=6
只显示category为6的数据
select * from table limit 0,1
只显示
1          1001select * from table limit 2,1
只显示
1          2048select * from table GROUP BY category
只显示
1         1001
5         5895
8         2684
9         7896

解决方案 »

  1.   

    SELECT DISTINCT category,model FROM table;
      

  2.   

    SELECT *
    FROM [table]
    GROUP BY category这样好像不行吧。我以前做个,但是现在没有找到。
      

  3.   

    用子查询来实现吧:
    select * from table a where( category in(select top 1 * from table b where b.category=a.category))
      

  4.   

    假设有以下一段数据:
    category    model
    _____________________________________
    1          1001
    1          1358
    1          2048
    5          5895
    5          6589
    8          2684
    8          6485          
    9          7896 
    -------------------------------------
    现在我想求出它们中的category唯一的一行数据
    就象distinct on (category)一样,但在MYSQL中没有
    category  model
    -------------------------------------
    1         1001
    5         5895
    8         2684
    9         7896
    -------------------------------------
    只要得到唯一的一行数据就行了,有什么语句在MYSQL和PostgreSQL中同时实现呢?
    不用程序代码控制,要纯的SQL实现。可以实现吗?select category,min(model) as model from tablename group by category
    or
    select category,max(model) as model from tablename group by category
      

  5.   

    iamyuqing(天草) ( ) 信誉:100 
    select category,min(model) as model from tablename group by category
    or
    select category,max(model) as model from tablename group by category这倒是个好主意,不知道MYSQL中有没有MIN()函数,我先试一下。
      

  6.   

    select category ,min(model) from tablename group by category  having count(*)=1