You find out here that id is not supplied to the script.
You give it a value so that any value in the database will be returned.
You could also give it some default value or give an error message and exit you're script.
LIKE "%" will allow ANY value, so if ID is not present it will allow any value.
You could check if ID is supplied to you're script and if it is not remove the %%.
LIKE is used for string-comparison.
Also, if you're trying to select a specific item you could better use:
Code:
where id = 12
, or when you want a range:
Code:
where id > 12 and id <40
It will execute faster.
The speed will not really be noticed on small tables, but the moment they get much bigger you'll notice the difference.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.