Hi,
I'm trying to write a script that will allow a user to search my database for peoples names or their year of birth.
I was thinking along the lines of:
SELECT * FROM my_db WHERE first_name LIKE '%$searchString%'
Is the above a good way of searching for somebodies name?
I'm strugging with searching for the year of birth because ideally I want to make it check within 5 years either way.
For instance:
SELECT * FROM my_db WHERE (birth_year - '$inputYear')<=5 OR ('$inputYear' - birth_year)<=5
So... my questions are:
Is the first example the best way of searching for a name from a user input within a database?
Can someone help me with the sql syntax for my second query?
Many thanks for all your help
Cheers
John ;-)
I don't make mistakes, I'm merely beta-testing life.
I'm trying to write a script that will allow a user to search my database for peoples names or their year of birth.
I was thinking along the lines of:
SELECT * FROM my_db WHERE first_name LIKE '%$searchString%'
Is the above a good way of searching for somebodies name?
I'm strugging with searching for the year of birth because ideally I want to make it check within 5 years either way.
For instance:
SELECT * FROM my_db WHERE (birth_year - '$inputYear')<=5 OR ('$inputYear' - birth_year)<=5
So... my questions are:
Is the first example the best way of searching for a name from a user input within a database?
Can someone help me with the sql syntax for my second query?
Many thanks for all your help
Cheers
John ;-)
I don't make mistakes, I'm merely beta-testing life.