gpt4 book ai didi

mysql 不在语句中,不工作

转载 作者:行者123 更新时间:2023-11-30 01:25:02 26 4
gpt4 key购买 nike

您好,我有以下查询,但它仍然给出指定不给我的结果。这有什么问题吗?

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 in 语句本应该过滤掉这些内容,但事实并非如此。

0   180212
1 573165
2 573165
3 632899
4 632141
5 647171

最佳答案

使用此查询:

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

您需要在所有值上添加 ',因为这些值是不同的。并且您在开头和结尾处都将其视为单个字符串。

关于mysql 不在语句中,不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18096117/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com