For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > April 2006 > subquery and LIMIT









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 subquery and LIMIT
persh

2006-04-22, 3:59 am

MySQL version : 5.0.18

I have the following query:

select p.products_id products p where p.products_id in (select
c.anonymous_id from c1 c order by c.satisfaction DESC LIMIT 5);

According to my version of MySQL I can't use LIMIT in the subselect. Is
there another way I can limit the number of lines returned from my subselect
? I need to cut the number of lines at the subselect level because the order
is based on the field satisfaction (I want the top 5 entries based on
satisfaction) which is not available in the products table.

Any help would be appreciated


strawberry

2006-04-22, 8:05 am

Would it work to reverse the query, so left join p on c?

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com