首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mysql不在语句中,不工作

mysql不在语句中,不工作
EN

Stack Overflow用户
提问于 2013-08-07 06:27:53
回答 1查看 55关注 0票数 0

嗨,我有以下的查询,但它仍然给我的结果,是指定的不给我。这个没在里面有什么问题?

代码语言:javascript
复制
select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id from hierarchy left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn where taxonomic_units.rank_id = 220 and hierarchy.hierarchy_string LIKE '%180211%' and taxonomic_units.tsn not in ('180212') order by rand() limit 1

select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id from hierarchy left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn where taxonomic_units.rank_id = 220 and hierarchy.hierarchy_string LIKE '%180210%' and taxonomic_units.tsn not in ('180212,573165') order by rand() limit 1

select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id from hierarchy left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn where taxonomic_units.rank_id = 220 and hierarchy.hierarchy_string LIKE '%180130%' and taxonomic_units.tsn not in ('180212,573165,573165') order by rand() limit 1

select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id from hierarchy left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn where taxonomic_units.rank_id = 220 and hierarchy.hierarchy_string LIKE '%179913%' and taxonomic_units.tsn not in ('180212,573165,573165,585192') order by rand() limit 1

select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id from hierarchy left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn where taxonomic_units.rank_id = 220 and hierarchy.hierarchy_string LIKE '%158852%' and taxonomic_units.tsn not in ('180212,573165,573165,585192,624896') order by rand() limit 1

这是复制的结果,我的not语句应该过滤掉那些,但是它没有。

代码语言:javascript
复制
0   180212
1   573165
2   573165
3   632899
4   632141
5   647171
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-07 06:31:57

使用此查询:

代码语言:javascript
复制
select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id   
   from hierarchy 
       left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn 
       where taxonomic_units.rank_id = 220 
             and hierarchy.hierarchy_string LIKE '%158852%' 
             and taxonomic_units.tsn not in ('180212','573165','573165','585192','624896') 
      order by rand() limit 1

您需要在所有值上添加',因为这些值是不同的。你已经在开始和结束时给予它作为一个单一的字符串。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18096117

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档