David
David

Reputation: 14404

Problem using LIMIT in a MySQL subquery?

I have a SQL query as follows

SELECT * FROM epf_application WHERE application_id IN
(SELECT application_id FROM epf_application_device_type WHERE device_type_id IN
(SELECT device_type_id FROM epf_device_type WHERE name="someDevice") LIMIT 30) LIMIT 30

When I run it in phpMyAdmin, I get the following error

1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

From the error, I am guessing that there is a problem with placing LIMIT in a subquery. Any suggestions on how I can fix this?

Upvotes: 0

Views: 852

Answers (1)

josh.trow
josh.trow

Reputation: 4901

SELECT 
 ea.* 
FROM 
 epf_application ea JOIN epf_application_device ead 
  ON ead.application_id = ea.application_id 
 JOIN epf_device_type edt 
  ON edt.device_type_id = ead.device_type_id 
WHERE 
 edt.name = 'someDevice' 
LIMIT 30

Upvotes: 1

Related Questions