Hey, first I use SQL + PHP the type of DB is MYSQL.
I have a column with the many strings, but I want to search the string 08/08/10 if it exists 5 times for example in the column, how do I do it?
** If I will do:
SELECT * FROM x WHERE y LIKE '%08/08/10%'
Maybe it exists, but I don't know if 5 times..
Thank you very much!
select count(1) from x where y like '%08/08/10%'
-outputs exact number of rows that have y like '%08/08/10%'
no group by needed in this particular case.
fetch rows where the string exists at least once and use php (eg substr_count) to count occurrences.
foreach($db->fetchAll(" where y like '%blah%' ") as $rec)
if(substr_count($rec->y, "blah") == 5)
bingo...
it also may help to tell us more about your problem - maybe there are better ways to structure the database
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.