tags:

views:

31

answers:

1

Hi all,

I have the following table.

mysql> select * from consumer2;

SERVICE_ID  SERVICE_TYPE  CONSUMER_FEEDBACK
31               PRINTER       1
32               PRINTER      -1
33               PRINTER       0
34               PRINTER      -1
35               PRINTER       0
31               PRINTER       0
32               PRINTER       1
35               PRINTER       1
31               PRINTER       0

From the above table i need to select the bottom 4 values using mysql i need to get the output as follows

SERVICE_ID       SERVICE_TYPE        CONSUMER_FEEDBACK
31               PRINTER              0
32               PRINTER              1
35               PRINTER              1
31               PRINTER              0

Please help me.Thank u in advance.

+1  A: 

If you would like the rows to be returned in the order they were inserted in, you'd probably have to use two queries. First, get the number of rows in the table.

SELECT count(*) FROM consumer2

Let's say the count is 10. We subtract 4, from it, leaving 6.

SELECT * FROM consumer2 LIMIT 6, 4

The reason why you need two queries is because MySQL does not allow subqueries in LIMIT statements.

Dumb Guy