首页 > 技术文章 > sql查询不在这个范围内的。例如,a不在b中出现的

bulter 2021-09-29 13:50 原文

 

 

 解释:此处查询id不在pid出现以/qwe开头userId为15的数据。子查询加上where是为了加快查询效率。

 

SELECT * from file where filePath like concat( "/qwe", '%') and userId =15 and  id NOT IN(SELECT pid from file where filePath like concat( "/qwe", '%') and userId =15)

 

推荐阅读