Home > Archive > PHP SQL > August 2006 > Sub query generating errors in MySQL only
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 |
Sub query generating errors in MySQL only
|
|
| Seansan 2006-08-13, 7:58 am |
| 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
| |
| J.O. Aho 2006-08-13, 7:58 am |
| 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...ery-errors.html
//Aho
| |
| Seansan 2006-08-13, 6:58 pm |
|
J.O. Aho wrote:
> Seansan wrote:
>
>
> 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...ery-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?
| |
| J.O. Aho 2006-08-13, 6:58 pm |
| 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
| |
| Webwasp 2006-08-13, 6:58 pm |
| Upgrade, get with the time bro!
"J.O. Aho" <user@example.net> wrote in message
news:4k90c1Fb2qpdU1@individual.net...
> Seansan wrote:
>
>
> 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
|
|
|
|
|