views:

70

answers:

2

Let say i have querry 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.

+1  A: 
SELECT * FROM YourTable WHERE YourField LIKE '%0912%'
Rubens Farias
It should be noted that no known databases optimize LIKE '%%' queries... meaning that no indexes will be used. Only LIKE 'prefix%' are optimal, as you need a common prefix to use an index.
Pestilence
@Pestilence, I agree with you but OP said "includes", so I had to guess.
Rubens Farias
+1  A: 

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

KornP