Forum Moderators: coopster
I construct a select statement using input from a user form...
$query="SELECT * FROM tblPeople where fldTelNumber='$frmTelNumber' ORDER BY `fldDateCreated` DESC";
However - if the user input is 123 and in the mqSQL db there are the following tel numbers...
123 and 123456 - my select statement is returning both? I was expecting it only to return the one that it matches exactly i.e. 123?
Am I able to refine the select statement so that it ONLY returns the exact value entered by the user?
Many thanks
SELECT * FROM tblPeople where fldTelNumber='123' ORDER BY `fldDateCreated` DESC
That query, when run against either a character or numeric column definition (fldTelNumber), will return only those rows where fldTelNumber has the exact value of 123.
Dump the $query to your browser to be sure.
$query="SELECT * FROM tblPeople where fldTelNumber='$frmTelNumber' ORDER BY `fldDateCreated` DESC";
exit("$query");
...