I want to make a select query to search seeking person between min and max ages. This is how search values comes from my search form.
Array
(
[iam] => Man
[seeking] => Woman
[age_min] => 18
[age_max] => 19
[country_id] => 25
)
I have stored these values in two mysql tables. One is user
and other one is Countries
. My problem is there is not a column in user table to store user's age. Age is calculating according to the users Date of Birth and user table have a column to store users DOB.
My users
table something like this:
CREATE TABLE IF NOT EXISTS users (
user_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
country_id SMALLINT UNSIGNED NOT NULL,
username VARCHAR(20) NOT NULL,
email varchar(40) NOT NULL,
first_name VARCHAR(30) DEFAULT NULL,
sex ENUM('Male', 'Female') DEFAULT 'Male',
dob VARCHAR(10) NOT NULL,
address VARCHAR(40) DEFAULT NULL,
city VARCHAR(25) NOT NULL,
last_login TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
date_registered TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (user_id),
UNIQUE (email),
UNIQUE (username)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
In country table it has country_id
and country_name
.
So. Can I know is there a way to do this using MySql SELECT
query.
Hope somebody may help me out.
Thank you.