mysql view with user variables
check out this one: https://stackoverflow.com/questions/2281890/can-i-create-view-with-parameter-in-mysql

ot you can crate sp for this select
 http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html