MySQL Query WHERE MONTH

I am trying to create a query that SELECTS data out of a DB the has a date equal to the current month.  The following query fails at: WHERE MONTH('date') = MONTH(CURDATE()) AND

	$sql->query("SELECT doctor_doctor.doctor_id, doctor_doctor.first_name AS first_name, doctor_doctor.last_name AS last_name, doctor_schedule.doctor_id, doctor_schedule.schedule_date AS date, doctor_schedule.time AS time, doctor_schedule.location_id
	FROM doctor_doctor, doctor_schedule
	WHERE MONTH('date') = MONTH(CURDATE()) AND doctor_doctor.doctor='1' AND doctor_doctor.doctor_id=doctor_schedule.doctor_id AND doctor_schedule.location_id='1' 
	ORDER BY date DESC");

Open in new window

LVL 8
rgranlundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David KrollCommented:
$sql->query("SELECT doctor_doctor.doctor_id, doctor_doctor.first_name AS first_name, doctor_doctor.last_name AS last_name, doctor_schedule.doctor_id, doctor_schedule.schedule_date AS date, doctor_schedule.time AS time, doctor_schedule.location_id
	FROM doctor_doctor, doctor_schedule
	WHERE MONTH(doctor_schedule.schedule_date) = MONTH(CURDATE()) AND doctor_doctor.doctor='1' AND doctor_doctor.doctor_id=doctor_schedule.doctor_id AND doctor_schedule.location_id='1' 
	ORDER BY date DESC");

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgranlundAuthor Commented:
@dkrollCTN Do you have any idea how I would write it so I can advance it, one month at a time?
0
David KrollCommented:
You can do:

WHERE MONTH(doctor_schedule.schedule_date)  = MONTH(CURDATE()) + 1

Not sure if that's what you're asking
0
rgranlundAuthor Commented:
The query shows the current month but Id like to incorporate a "Next Month" and Prev Month" Button but I'm not sure were to start
0
David KrollCommented:
Next month would be
WHERE MONTH(doctor_schedule.schedule_date)  = MONTH(CURDATE()) + 1

prev month

WHERE MONTH(doctor_schedule.schedule_date)  = MONTH(CURDATE()) - 1
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.