DBMNG数据库管理与应用

所有存在都是独创。
当前位置:首页 > MySQL > 常见问题

mysql 子查询里面不能有limit

select shop_product.productid,shop_product.name,shop_product.icon,shop_product.price,shop_product.unit,shop_product.description,shop_product_category.catid from shop_product

inner join shop_product_category

on shop_product.productid in (select productid from shop_product_category where catid = 1 limit 10) and shop_product.productid = shop_product_category.productid

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

子查询里面不能有limit
于是乎
select shop_product.productid,shop_product.name,shop_product.icon,shop_product.price,shop_product.unit,shop_product.description,shop_product_category.catid from shop_product inner join (select productid from shop_product_category where catid = 1 limit 10) as pro_all on shop_product.productid = pro_all.productid inner join shop_product_category on shop_product.productid = shop_product_category.productid




这样的语句是不能正确执行的。

select * from table where id in (select id from table limit 10);
但是,只要你再来一层就行,如:
select * from table where id in (select t.id from (select * from table limit 10)as t)


本站文章内容,部分来自于互联网,若侵犯了您的权益,请致邮件chuanghui423#sohu.com(请将#换为@)联系,我们会尽快核实后删除。
Copyright © 2006-2023 DBMNG.COM All Rights Reserved. Powered by DEVSOARTECH            豫ICP备11002312号-2

豫公网安备 41010502002439号