Hello, if someone could help me out I would appreciate it. Currently I use this statement to select the 25 records from a database with the most hits. $sql = "SELECT * FROM sh_urls ORDER BY vi DESC LIMIT 25"; PHP: I would like to select from the field "sh_urls" all records that contact a specific word in that field. How do I do this? Thanks so much in advance.
The field contains urls, right? The slow way is $sql = "SELECT * FROM `sh_urls` WHERE lower(`sh_urls`) like '%{$str}%' ORDER BY vi DESC LIMIT 25"; PHP: so if you are searching for "king" then www.andrewking.co.nz will be returned You can put some regex in there to be smarter about the search.
You can do like this: $sql = "SELECT * FROM sh_urls WHERE vi LIKE '%specword%' ORDER BY vi DESC"; Code (markup):
It's different because it dumps less data into the array. The wildcard * dumps all the fields, whereas calling a single field is going to result in faster code because it isn't iterating a bunch of stuff you don't need.
We both used * and the issue isn't the fields that are returned but the filter to get the right data.