You are on page 1of 2

1. Display full name of all employees whose city is RWP.

SELECT `fname`, `lname` FROM `employee` WHERE `city`='RWP'

2. Display details of those authors whose name is either Ali or Rida or Javed
without using comparison/relational operator.
SELECT * FROM `author` WHERE `Name` IN ('ali','rida','javed')

3. Display details of all those authors whose salary is less than 25000 or salary
greater than 30000 using between operator.
SELECT * FROM `employee` WHERE `salary` NOT BETWEEN 25000 AND 30000

4. Display details of all those male authors who are living in isb or lhr.
SELECT * FROM `author` WHERE `Gender` = 'male' AND `City` IN ('isb','lhr')

5. Display details of all those employees whose fname is neither akram nor asif
nor ahmed without using in operator.
SELECT * FROM `employee` WHERE `fname` != 'akram' AND `fname` != 'asif' AND `fname` !
='ahmed'

6. Display details of all those employees whose lname starts with a and whose
fname second letter is a vowel character i.e. (a,e,i,o,u).
SELECT * FROM `employee` WHERE `lname` LIKE 'a%' AND `fname` LIKE '_[a-u]%'

7. Display details of all those authors whose name contains less than 5
characters.
SELECT * FROM `author` WHERE length (Name) <5

8. Display fname of 3 employees who are earning least.


SELECT `fname` FROM `employee` ORDER BY `salary` LIMIT 3

9. Display details of all authors in such a way that female authors are shown
before the male authors.
SELECT * FROM `author` ORDER BY `Gender` ASC

10. Display the unique cities from author table.

SELECT DISTINCT `City` FROM `author`


11. Display details of all those employees who are getting salary greater than
50000 or whose city is ISB.
SELECT * FROM `employee` WHERE `salary`>50000 OR `city`='isb'

12. Display details of all those authors whose age is less than equal to 50 and
age is greater than equal to 20 without using relational operators i.e. (>=, <=)
SELECT * FROM `author` WHERE `Age` BETWEEN 20 AND 50

13. Display all authors.

SELECT `Name` FROM `author`

14. Display details of all those employees whose salary is between 20000 and
30000 without using between operator.
SELECT * FROM `employee` WHERE `salary`>=20000 AND `salary`<=30000

15. Display details of all those authors whose city is either rwp or isb using in
operator, in such a way that youngest author should be shown at the top.
SELECT * FROM `author` WHERE `City` IN ('rwp','isb') ORDER BY `Age`

You might also like