TumacLumber
asked on
MYSQL - LIKE with variable and wildcard - Syntax help
I am having problem with syntax for a query that grabs a variable value and then a wildcard
$q="SELECT poID FROM in_transit_summary WHERE poID LIKE ".$poID."% group by poID";
I keep getting invalid qry error
$q="SELECT poID FROM in_transit_summary WHERE poID LIKE ".$poID."% group by poID";
I keep getting invalid qry error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. Had my single quote in wrong places...
$q="SELECT poID FROM
in_transit_summary WHERE poID
LIKE '$poID%' group by poID";
To be clear, if poID is a string (varchar), then you need single quotes around it when searching. If it is a number, it will need to be cast to a varchar first, and the same LIKE expression.