I have attribute of datatype longtext in which there is on average 3 MB of plain text. Without using fulltext search or any kind I use this query:
select column1 from table where column1 like '%abc5%';
The output for each row is the whole content of column1. So if I would like to color matched data in PHP I would have to use:
<?php
preg_replace('/(abc5)/i', "<b>$1</b>", $row->column1);
....
?>
This goes throught all content. Is the开发者_运维百科re a way that I could do something like this:
select show_first_N_matched(column1) from table where column1 like '%abc5%';
Let's say I have for example data like this:
abc1 NA NA NA NA NA NA
abc2 NA NA NA NA NA NA
abc3 NA NA NA NA NA NA
abc4 NA NA NA NA NA NA
abc5 NA NA NA NA NA NA
abc4 NA NA NA NA NA NA
abc5 NA NA NA NA NA NA
The first query would return everything. The second gives only this:
abc5 NA NA NA NA NA NA
abc5 NA NA NA NA NA NA
精彩评论