select * from member where data!=” order by time desc Limit 0,10
The data in the first ten lines are arranged in reverse order above, how can we further compare the number of key words in these ten lines of data?
That is: data like ‘%$keyword%’ How many of the above 10 items contain the keyword?
17 solutions
#1
select *
from (
select * from member where data!=” order by time desc Limit 0,10
)T
where data like ‘%$keyword%’
#2
select * from
(select * from member where data!=”order by time desc limit 0,10
)a
where data like’%$keyword%’
#3
I tested it, and got an error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
Please help me
#4
It is also wrong to replace T with a: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
Please help me to have a look again! Thanks
#5
$sql=”select * from member where `data` like ‘%$keyword%’ order by `time` desc Limit 0,10″;
#6
What is your code, what version of MYSQL
#7
At the beginning, I thought so too, but this can only get the value of data=$keyword, for example, if there are a thousand pieces of data, it will search for the first 10 pieces of the total number of pieces containing $keyword. And I want to get 10 items in reverse order first, and then compare how many of these 10 items contain $keyword
#8
It has nothing to do with the code:
$query=”select * from
(select * from member where data!=”order by time desc limit 0,10
)a
where data like’%$keyword%’
“;
$result=$obj_db->simplequery($query);
while ($arr=$obj_db->fetchrow($result,DB_FETCHMODE_ASSOC))
{
$list.=”$arr[data]
“;
}
MYSQL installed and debugged locally, a bit old:
MySQL 4.0.24-nt
#9
So what’s wrong with your code. Your data and time fields are reserved words and need to be escaped with `data` `time`.
#10
Could it be that a mysql statement cannot be completed? Can you output 10 first:
select * from member where data!=” order by time desc Limit 0,10
Output 10, and then
foreach ($list as $v){
Compare the same data as $keyword to get $count
}
if ($count>0){
echo “”;
exit();
}
Only thinking, which expert can write out the code?
Or is there an easier way?
#11
It has nothing to do with this, it is also wrong to change the whole to `mydata` `mytime`:
select * from
(select * from member where mydata!=”order by mytime desc limit 0,10
)a
where mydata like’%$keyword%’
#12
You do not provide error information. Who knows what went wrong.
Processing in php is also possible.
$count=0;
foreach ($list as $v){
if($v==$keyword) $count++;
}
if ($count>0){
echo “”;
exit();
}