Sub query generating errors in MySQL only

Sub query generating errors in MySQL only

am 13.08.2006 13:35:49 von Seansan

Hi there,

I have this query below and the SELECT COUNT statements are generating
errors in MySQL with php and I have no clue why. I would like to be
able to do this because this also works for other DB's. Any ideas?

Kind regards, Seansan

SELECT ttrss_feeds.*,
SUBSTRING(last_updated,1,19) AS last_updated_noms,
(SELECT COUNT(ttrss_entries.id) FROM ttrss_entries,
ttrss_user_entries
WHERE ttrss_user_entries.feed_id = ttrss_feeds.id AND
ttrss_user_entries.ref_id = ttrss_entries.id AND
owner_uid = 'admin') AS total,
(SELECT COUNT(ttrss_feeds.id) FROM ttrss_entries,ttrss_user_entries
WHERE feed_id = ttrss_feeds.id AND unread = 'true'
AND ttrss_user_entries.ref_id = ttrss_entries.id
AND owner_uid = 'admin') as unread,
cat_id,
last_error,
ttrss_feed_categories.title AS category,
ttrss_feed_categories.collapsed
FROM ttrss_feeds
LEFT JOIN ttrss_feed_categories ON (ttrss_feed_categories.id =
cat_id)
WHERE ttrss_feeds.owner_uid = 'admin' AND parent_feed IS NULL

Re: Sub query generating errors in MySQL only

am 13.08.2006 13:39:48 von Shion

Seansan wrote:

> I have this query below and the SELECT COUNT statements are generating
> errors in MySQL with php and I have no clue why. I would like to be
> able to do this because this also works for other DB's. Any ideas?

Without even looking at the query, I would guess you have MySQL 4.0 or older
version, which don't support subqueries, what you need to do is to upgrade
your MySQL to a later version, 5.0 which should be the current stable one.

For more info about subquery errors, check this page at mysql.com:
http://dev.mysql.com/doc/refman/5.0/en/subquery-errors.html



//Aho

Re: Sub query generating errors in MySQL only

am 13.08.2006 17:15:00 von Seansan

J.O. Aho wrote:
> Seansan wrote:
>
> > I have this query below and the SELECT COUNT statements are generating
> > errors in MySQL with php and I have no clue why. I would like to be
> > able to do this because this also works for other DB's. Any ideas?
>
> Without even looking at the query, I would guess you have MySQL 4.0 or older
> version, which don't support subqueries, what you need to do is to upgrade
> your MySQL to a later version, 5.0 which should be the current stable one.
>
> For more info about subquery errors, check this page at mysql.com:
> http://dev.mysql.com/doc/refman/5.0/en/subquery-errors.html
>
>
>
> //Aho

Thanks for your answer. I have version MySQL 3.23.58, this is probably
it. Anybody any hints on how to fix this for lower versions?

Re: Sub query generating errors in MySQL only

am 13.08.2006 17:55:45 von Shion

Seansan wrote:

> Thanks for your answer. I have version MySQL 3.23.58, this is probably
> it. Anybody any hints on how to fix this for lower versions?

You need to make two extra queries and fetch the "total" and "unread"
separately from the main select and then in php merge the three selects to
your result array (in case you do save thing in a such).

If this won't be an option for you, then you need to upgrade to MySQL 4.1.


//Aho

Re: Sub query generating errors in MySQL only

am 14.08.2006 01:25:17 von Webwasp

Upgrade, get with the time bro!
"J.O. Aho" wrote in message
news:4k90c1Fb2qpdU1@individual.net...
> Seansan wrote:
>
>> Thanks for your answer. I have version MySQL 3.23.58, this is probably
>> it. Anybody any hints on how to fix this for lower versions?
>
> You need to make two extra queries and fetch the "total" and "unread"
> separately from the main select and then in php merge the three selects to
> your result array (in case you do save thing in a such).
>
> If this won't be an option for you, then you need to upgrade to MySQL 4.1.
>
>
> //Aho