shaytac
shaytac

Reputation: 4014

How to search a numeric value in a database

Let's say I have query structured like below which indicates dates

search.asp?date=091210

I want to find each record that includes 0912 string how can I inquire it on the link structure.

Upvotes: 0

Views: 215

Answers (2)

Kurt Pattyn
Kurt Pattyn

Reputation: 2788

Indeed, never trust anything that is given on a URL. What you should do, is parse the date variable and split it up in a month, day and year part. Be sure to do the necessary sanity checks. Then you can issue a query like: SELECT * FROM yourTable WHERE MONTH(dateColumn) = month AND YEAR(dateColumn) = year

Upvotes: 1

Rubens Farias
Rubens Farias

Reputation: 57956

SELECT * FROM YourTable WHERE YourField LIKE '%0912%'

Upvotes: 1

Related Questions