Q:

Display from the 5th row from the MySQL 'empdata' table, set limit 2 and order by name

1

Display the nth row from MySQL table

Display from the 5th row from the MySQL 'empdata' table, set limit 2 and order by name

Suppose, we have the following records -

CREATE TABLE IF NOT EXISTS `empdata` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` char(25) NOT NULL,
  `address` varchar(100) NOT NULL,
  `phone` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
INSERT INTO `empdata` (`id`, `name`, `address`, `phone`) VALUES
(6, 'Lussi', 'K-91, Roy Apartment', 909030309),
(4, 'Joya', '15, CP Colony', 342345329),
(5, 'Ammy', '25, JP Colony', 239848342),
(2, 'Priska', '122, JP Colony', 890040908),
(3, 'Abhi', '5, Bank Street', 675748389),
(1, 'Anjali', '121, Vakundh Dham', 840932345);

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

SELECT * FROM `empdata` ORDER BY name LIMIT 2 OFFSET 4;

This returns the following output -

+----+--------+---------------------+-----------+
| id | name   | address             | phone     |
+----+--------+---------------------+-----------+
|  6 | Lussi  | K-91, Roy Apartment | 909030309 |
|  2 | Priska | 122, JP Colony      | 890040908 |
+----+--------+---------------------+-----------+

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now