By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE employee (`empid` INTEGER, `Name` VARCHAR(8), `Position` VARCHAR(10), `Office` VARCHAR(9), `Age` INTEGER, `is_active` BOOLEAN DEFAULT TRUE);
INSERT INTO employee (`empid`, `Name`, `Position`, `Office`, `Age`) VALUES
('1', 'Airi', 'Accountant', 'Tokyo', '33'),
('2', 'Angelica', 'Officer', 'London', '47'),
('3', 'Ashton', 'Technical', 'Francisco', '66'),
('4', 'Bradley', 'Software', 'London', '41'),
('5', 'Brenden', 'Engineer', 'Francisco', '28'),
('6', 'qodjf', 'Accountant', 'Tokyo', '33'),
('7', 'Angelica', 'Officer', 'New York', '50'),
('8', 'Ashton', 'Technical', 'Francisco', '30'),
('9', 'zxysz', 'Software', 'London', '50'),
('10', 'Brenden', 'Engineer', 'Francisco', '28');
Records: 10 Duplicates: 0 Warnings: 0
SELECT *
FROM employee
WHERE is_active = 1
ORDER BY empid > 1 DESC, empid LIMIT 3
empid | Name | Position | Office | Age | is_active |
---|---|---|---|---|---|
2 | Angelica | Officer | London | 47 | 1 |
3 | Ashton | Technical | Francisco | 66 | 1 |
4 | Bradley | Software | London | 41 | 1 |
SELECT *
FROM employee
WHERE is_active = 1
ORDER BY empid > 9 DESC, empid LIMIT 3
empid | Name | Position | Office | Age | is_active |
---|---|---|---|---|---|
10 | Brenden | Engineer | Francisco | 28 | 1 |
1 | Airi | Accountant | Tokyo | 33 | 1 |
2 | Angelica | Officer | London | 47 | 1 |
SELECT *
FROM employee
WHERE is_active = 1
ORDER BY empid > 10 DESC, empid LIMIT 3
empid | Name | Position | Office | Age | is_active |
---|---|---|---|---|---|
1 | Airi | Accountant | Tokyo | 33 | 1 |
2 | Angelica | Officer | London | 47 | 1 |
3 | Ashton | Technical | Francisco | 66 | 1 |