Find values that start with a user defined letter
Posted 20 January 2006 - 06:59 PM
I was wondering how you would write a query that would only contain the values of a defined field which start with a defined letter. I have a last name field and I want the user to have the option to display only the last names that start with a letter they specify. EX: Find last names that start with A,B... etc.
Thanks for the help!
Posted 20 January 2006 - 08:37 PM
My initial query is as follows:
$sql = "SELECT id, sid, last, first FROM student_data_gen WHERE semester = '$semester' ORDER BY last";
What I want to do is find the students by semester but also find only the last names that begin with the user defined letter like, A, B etc.
How would I use LEFT(last, 1) component in the previous code? Again, thanks for all your help!
Posted 23 January 2006 - 03:26 PM
Then add a "WHERE LEFT(last,1)='<your letter here>'" to your query.
Works great, thanks!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users