表product
id,name,price
1 ,aa,42
2,bb,22
3,bb,33用一个sql句子取按价格(price)排序后的第二条记录。谢谢大家

解决方案 »

  1.   

    表product
    id,name,price
    1 ,aa,42
    2,bb,22
    3,bb,33select * from product order by price limit 1,2;不在公司,没调试过,你看看对不对
      

  2.   

    mysql> create table product( id int ,name varchar(20),price int);
    Query OK, 0 rows affected (0.01 sec)mysql> insert into product  select 1,'aa',42 union select 2,'bb',22 union select 3,'bb',33 ;
    Query OK, 3 rows affected (0.00 sec)
    Records: 3  Duplicates: 0  Warnings: 0mysql> select * from product;
    +------+------+-------+
    | id   | name | price |
    +------+------+-------+
    |    1 | aa   |    42 |
    |    2 | bb   |    22 |
    |    3 | bb   |    33 |
    +------+------+-------+
    3 rows in set (0.00 sec)mysql> select * from product order by price limit 1,1;
    +------+------+-------+
    | id   | name | price |
    +------+------+-------+
    |    3 | bb   |    33 |
    +------+------+-------+
    1 row in set (0.00 sec)