I have a sql database which stores peoples name in, for example
I want to do a query on this table, but just with the first 2 characters. For example, if I do a search for
then it would return
and every other row which starts with Da.
There can also be numbers mixed in, for example
The query I use is
$sql = "SELECT * FROM db WHERE `firstname` = '".$firstname."' ORDER BY RAND()";
But I want to check just the first 2 characters of the field
Can this be done with ease?