herdofturtles21 herdofturtles21 - 8 months ago 23
MySQL Question

How to get value by only giving part of a name in a query

I need to get an id from a query right now my table looks like this

id = 2000 name = 'johnson, bob' ssn='1234'

My login page asks for last name and ssn and then I use that info in a query to get their id.

Im trying to figure out how to write this query when the name field contains BOTH lastname, firstname. I am using mysql.


Write query like this: customize name parameter like this before send it to query

string nameValue={name from ui}+",%";

SQL query:

Select id 
from {your table name}
where ssn={ssn value from ui} and name Like nameValue;

Let me know if it works for you