Consider a table 'EMPLOYEE':
EMPID EmpName DOB DOJ Salary E001 Sumit 1994-10-10 2020-05-05 50000 E002 Ajay 1995-08-11 2021-07-08 60000 E003 Amit 1993-04-14 2012-04-09 70000
If we have to select DAY, MONTH and YEAR of birth of all EMPLOYEE, which of the following query should be used?
Consider a table 'EMPLOYEE':
| EMPID | EmpName | DOB | DOJ | Salary |
|---|---|---|---|---|
| E001 | Sumit | 1994-10-10 | 2020-05-05 | 50000 |
| E002 | Ajay | 1995-08-11 | 2021-07-08 | 60000 |
| E003 | Amit | 1993-04-14 | 2012-04-09 | 70000 |
If we have to select DAY, MONTH and YEAR of birth of all EMPLOYEE, which of the following query should be used?
Solution
Option 2 lists the three functions , and separated by commas. This returns the day, month and year as three separate columns for every employee, which is what the question asks for.
Option 1: in MySQL, || is the logical OR operator by default, so it does not join the values into one string and does not give three separate columns.
Option 3: SELECT * returns every column, including the full date, not the separate day, month and year.
Option 4: && is the logical AND operator, so it gives a single 0 or 1 result, not the date parts.
Related questions:
2025: 30 May Shift 2
2025: 13 May Shift 2
2025: 15 May Shift 2
2026: 26 May Shift 1