mysql if conditional help

Posted on 2011-05-11
Last Modified: 2012-06-27
help me write a query for mysql

i have a db with exp date

i want it to show only equal or above the current month and year

i tried below :
let say
curmonth : 05
curyear : 2011

query :
select * from members where expire_month >=  curmonth and expire_year >= curyear order by asc

but its skipping month 01 even the year is 2013

assist me with the right way for this query
Question by:mobileuni
    1 Comment
    LVL 142

    Accepted Solution

    select * from members where ( expire_month >=  curmonth and expire_year = curyear ) OR expire_year > curyear order by asc


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now