Multiple WHERE clauses in a Query

0 Kam N. · July 6, 2015
Hi everyone, I'm still fairly new to SQL, I was wondering what is the best way to to have two WHERE clauses in one query? I have a table that has columns time, name,shift. I want to say pick everything from the table between date 1 to take 10 and also want only ones where there shift is 'A' shift.


SELECT 
t_stamp,
name'
shift,
FROM Monthly
WHERE
t_stamp BETWEEN 'Date 1' AND 'Date 10' AND shift = 'A'

Or can i somehow use UNION

SELECT 
t_stamp,
name'
shift,
FROM Monthly
WHERE
t_stamp BETWEEN 'Date 1' AND 'Date 10'
UNION
SELECT 
t_stamp,
name'
shift,
FROM Monthly
WHERE
shift = 'A';

I'd appreciate the help. Thanks in advance 

Post a Reply

Replies

- page 2
Oldest  Newest  Rating
0 mike richardson · July 7, 2015
I need to know more about what you are doing. There are several options you can use. You can use an IF/ Else If In your code or CASE or IF in a stored procedure on your MySQL server.
  • 1
  • 2

SQL & Databases

113,953 followers
About

Everything SQL and Databases related in here!

Links
Moderators
Bucky Roberts Administrator