Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

$query="SELECT *, COUNT(*) FROM links WHERE "; ,,,,, Possible????

spidermonsterspidermonster Member Posts: 1
$query="SELECT *, COUNT(*) FROM links WHERE ";

if ($count==1){
$query.="keywords LIKE '%$keywords%' LIMIT $from, $max_results";
}
elseif($count>=1){
for($a=0;$a<$count;$a++){
$query.="keywords LIKE '%$pieces[$a]%'";
if($a != $count-1){
$query.=" OR ";
}
}
$query.="LIMIT $from, $max_results";
}

is this query possible?
$query="SELECT *, COUNT(*) FROM links WHERE ";

im getting this error:
MySQL Error: 1140: Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause

and i havent learned about any groups yet,,,
what do i do?

Comments

  • JonathanJonathan Member Posts: 2,914
    : $query="SELECT *, COUNT(*) FROM links WHERE ";
    :
    : if ($count==1){
    : $query.="keywords LIKE '%$keywords%' LIMIT $from, $max_results";
    : }
    : elseif($count>=1){
    : for($a=0;$a<$count;$a++){
    : $query.="keywords LIKE '%$pieces[$a]%'";
    : if($a != $count-1){
    : $query.=" OR ";
    : }
    : }
    : $query.="LIMIT $from, $max_results";
    : }
    :
    : is this query possible?
    : $query="SELECT *, COUNT(*) FROM links WHERE ";
    :
    : im getting this error:
    : MySQL Error: 1140: Mixing of GROUP columns (MIN(),MAX(),COUNT()...)
    : with no GROUP columns is illegal if there is no GROUP BY clause
    Getting an error is a good suggestion that it isn't possible. :-) Doing thet SELECT COUNT(*) FROM links WHERE on it's own would work.

    : and i havent learned about any groups yet,,,
    : what do i do?
    What you're trying to do, whether we can make the query work or not, is probably not desirable anyway. You are asking MySQL to return the total number of rows with every row that is returned. You don't need to do that explicitly, it's provided by the PHP mysql_num_rows function:-

    http://uk.php.net/manual/en/function.mysql-num-rows.php

    Which I suggest you use instead.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.