I had wroted query

SELECT r.`id`, COUNT(s.`id`) AS `sk` FROM `sodybos` as s RIGHT OUTER JOIN
`rajonai` as r ON (s.`rajonai_id` = r.`id`) GROUP BY r.`id`

But this query run's slow, now I want to optimize it, maybe write it without
JOIN command

If I wrote new query (it's more faster)

select r.id, count(s.id) as sk from rajonai as r, sodybos as s WHERE
s.rajonai_id = r.id group by r.id

It's work good, but I can't get rows which count(s.id) = 0

Example with 1 query I get

1|12
2|0
3|15
4|5
5|1

With second only

1|12
3|15
4|5
5|1

How to get and 2 row? Which count result = 0


-- 
Vaidas Zilionis aka Why2liz
http://www.why2liz.net
ICQ: 35174940
Mobile: +37061691393



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to