0

i have a table loans in a database with the schema that like this

loans
-----
period (vchar) ' but it contains number string
date
amt
user

i needed to select all the records from a loans where the the date + period is equal to or greater than current date. when i execute the query below

SELECT * 
FROM loans
WHERE DATE( DATE_ADD( DATE, INTERVAL period
DAY ) ) >= CURRENT_DATE
LIMIT 0 , 30

i get all the records in the loans table. what is the problem?

6
  • We need to see what period values look like. Commented May 21, 2013 at 0:58
  • Is pay_period intended as period? Are they different columns or is one a typo here? Commented May 21, 2013 at 1:02
  • @FreshPrinceOfSO: i update my post. the period is a varchar field, but its numeric Commented May 21, 2013 at 1:06
  • @Smith What does your data in that column look like? Commented May 21, 2013 at 1:07
  • @FreshPrinceOfSO numbers 15, 30, 10 etc Commented May 21, 2013 at 1:11

1 Answer 1

1

Is this what you're looking for?

SELECT columnList
FROM loans
WHERE CURDATE() < DATE_ADD(`date`, INTERVAL pay_period DAY)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.