Home > Archive > PHP SQL > January 2005 > select count(*) > @foobar
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
select count(*) > @foobar
|
|
|
| i have a query as follows and is unsure whether it is mysql or php:
$result = mysqli_query("SELECT COUNT(*) > @foobar AS status ....") where
it's suppose to get a one row value of either '0' or '1' (false or true)
if i were to do a SELECT COUNT(*) FROM...
i can use the php $row["COUNT(*)"] to refer to the index.
if i were to do a SELECT COUNT(*) AS status FROM...
i can use the php $row["status"] to refer to the index.
but in this case SELECT count > @foobar AS status,
refering to $row["status"] gives a empty value. however, running the
same query in mysql command prompt produces
+------+
|status|
+------+
| 1 |
+------+
php doesn't support such select statement? even array_keys($row) returns
empty.
anybody knows how to solve it? thank you very much.
| |
| Atlantis 2005-01-31, 3:58 pm |
| "-" <nobody@hoem.om> wrote in message news:41fd8eb5$1@news.starhub.net.sg...
> i have a query as follows and is unsure whether it is mysql or php:
>
> $result = mysqli_query("SELECT COUNT(*) > @foobar AS status ....") where
> it's suppose to get a one row value of either '0' or '1' (false or true)
>
> if i were to do a SELECT COUNT(*) FROM...
> i can use the php $row["COUNT(*)"] to refer to the index.
>
> if i were to do a SELECT COUNT(*) AS status FROM...
> i can use the php $row["status"] to refer to the index.
>
> but in this case SELECT count > @foobar AS status,
> refering to $row["status"] gives a empty value. however, running the
> same query in mysql command prompt produces
>
> +------+
> |status|
> +------+
> | 1 |
> +------+
>
> php doesn't support such select statement? even array_keys($row) returns
> empty.
>
> anybody knows how to solve it? thank you very much.
Not sure what the @ proceding foobar means, but something like this should
work...
SELECT IF(COUNT(*) > foobar, 1, 0) AS Status FROM `MyTable`;
|
|
|
|
|