Reputation: 13
new here and to MySQL. Wondering how I can combine these two queries together to get 1 output. I want to include all hours less or equal to 30, AND hours that equal exactly 40. I can get 2 outputs, but I am unsure how it would look if everything was put together.
The 2 commands are :
SELECT empID, hoursWorked FROM timesheet WHERE hoursWorked = 40;
SELECT empID, hoursWorked FROM timesheet WHERE hoursWorked <= 30;
Running MySQL v5.7.26 on Wampserver
Thanks !
Upvotes: 1
Views: 38
Reputation: 3970
Union/Union all both the queries
SELECT empID, hoursWorked FROM
timesheet WHERE hoursWorked = 40;
Union
SELECT empID, hoursWorked FROM
timesheet WHERE hoursWorked <= 30;
Or simplest way
SELECT empID, hoursWorked FROM
timesheet WHERE hoursWorked = 40
Or hoursWorked <= 30
Upvotes: 0
Reputation: 782693
Use OR
in the condition:
SELECT empID, hoursWorked
FROM timesheet
WHERE hoursWorked = 40
OR hourseWorked <= 30;
Upvotes: 1