[snip]
SELECT DISTINCT
      u.user_id,
      u.user_name,
      max(
        if(u.sex=2,25,0) +
        if(u.age=4,25,0) +
        if(u.country='gm',25,0)+
        if(l.language_id='de',25,0)
        )
        AS ranking,

      c.country_code,
      c.country,
      ct.city,
      l.language_id,
      u.age,
      u.sex
FROM userdb.user u, userdb.user_languages l, test.countries AS c

LEFT JOIN test.cities AS ct ON ct.ID = u.city

WHERE
  l.user_id = u.user_id
  AND u.country = c.country_code

GROUP BY u.user_id
HAVING ranking > 0
ORDER BY ranking desc
Limit 0,10
[/snip]
What are your table indexes? Can you do an EXPLAIN on the query?

Thanks!

Jay


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to