本文介绍了查询过于复杂。如何编码不正确的声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 显然,新手在这里。无论如何,我对如何接受这个问题感到有点困惑。我有一个查询表,我正在尝试创建。我正在尝试查看所有的streets.type值为null,但是 然后排除那些对于S.type而言为空的STREETNAME值但是 这些值是真的好的。查询如下: SELECT S.ID,S.ID2,S.PREFIX,S.STREETNAME,S.TYPE 来自街道的S WHERE S.STREETNAME不喜欢* HWY110 * AND S.STREETNAME不喜欢* HWY111 * AND S.STREETNAME不喜欢* HWY112 * AND S.STREETNAME不喜欢* HWY113 * AND S.STREETNAME不喜欢* HWY114 * AND S.STREETNAME不喜欢* HWY115 * AND S.STREETNAME不喜欢* HWY116 * AND S.STREETNAME不喜欢* HWY117 * AND S.STREETNAME不喜欢* HWY118 * AND S.STREETNAME不喜欢* HWY119 *和 等大约250多个值。 AND((S.TYPE)是空的)); 现在,一旦我得到这些值中的大约50个左右,我得到查询太多 复杂,我该如何实现? TIA 解决方案 2005年5月21日星期六23:07:59 -0700,ynott< yn *** @ hotmail.com>写道: 将值放在表格中。然后写: SELECT ... WHERE s.StreetName not in(select< FieldName> from < NewTable>) -Tom。 这里显然是新手。无论如何,我对如何解决这个问题感到有些困惑。我对我正在尝试创建的表进行查询。我正在尝试查看所有的streets.type值为null,但是然后排除那些对于S.type而言为空的STREETNAME值,但是确实没问题。查询如下: SELECT S.ID,S.ID2,S.PREFIX,S.STREETNAME,S.TYPE 来自街道作为S WHERE S.STREETNAME不喜欢* HWY110 * AND S.STREETNAME不喜欢* HWY111 * AND S.STREETNAME不喜欢* HWY112 * AND S.STREETNAME不喜欢* HWY113 * AND S.STREETNAME不喜欢* HWY114 * AND S.STREETNAME不喜欢* HWY115 * AND S.STREETNAME不喜欢* HWY116 * AND S.STREETNAME不喜欢* HWY117 * AND S.STREETNAME不喜欢* HWY118 * AND S.STREETNAME不喜欢* HWY119 *还有大约250多个值。 AND((S.TYPE)Null)); 现在,一旦我到达大约50个左右这些值,我得到查询太复杂,我怎么能做到这一点? TIA 完美。 Thx 2005年5月21日星期六23:24:29 -0700,Tom van Stiphout < no ********* ****@cox.net>写道: 2005年5月21日星期六23:07:59 -0700,ynott< yn *** @ hotmail.com>写道: 将值放在表中。然后写: SELECT ... WHERE s.StreetName not in(select< FieldName> from < NewTable>) -Tom。 这里显然是新手。无论如何,我对如何解决这个问题感到有些困惑。我对我正在尝试创建的表进行查询。我正在尝试查看所有的streets.type值为null,但是然后排除那些对于S.type而言为空的STREETNAME值,但是确实没问题。查询如下: SELECT S.ID,S.ID2,S.PREFIX,S.STREETNAME,S.TYPE 来自街道作为S WHERE S.STREETNAME不喜欢* HWY110 * AND S.STREETNAME不喜欢* HWY111 * AND S.STREETNAME不喜欢* HWY112 * AND S.STREETNAME不喜欢* HWY113 * AND S.STREETNAME不喜欢* HWY114 * AND S.STREETNAME不喜欢* HWY115 * AND S.STREETNAME不喜欢* HWY116 * AND S.STREETNAME不喜欢* HWY117 * AND S.STREETNAME不喜欢* HWY118 * AND S.STREETNAME不喜欢* HWY119 *还有大约250多个值。 AND((S.TYPE)Null)); 现在,一旦我到达大约50个左右这些值,我得到查询太复杂,我怎么能做到这一点? TIA Tom 你试过这个吗?它慢吗?我找到了NOT IN非常,非常好b / b 慢。出于这个原因,我同意将值放入 表中,但我建议在SQL中使用JOIN和WHERE CriteriaTable.StreetName为Null。 br /> 但也许这个想法不再相关,SQL和JET或其他什么 会优化NOT IN条件,以便它的执行速度快? Novice here obviously. Anyway, I''m a bit confused about how toapproach this. I have a query against a table that I''m trying tocreate. I''m trying to view all streets.type values that are null, butthen exclude those STREETNAME values that are null for the S.type butthat are really okay. The query goes like:SELECT S.ID, S.ID2, S.PREFIX, S.STREETNAME, S.TYPEFROM streets as SWHERES.STREETNAME Not Like "*HWY110*" ANDS.STREETNAME Not Like "*HWY111*" ANDS.STREETNAME Not Like "*HWY112*" ANDS.STREETNAME Not Like "*HWY113*" ANDS.STREETNAME Not Like "*HWY114*" ANDS.STREETNAME Not Like "*HWY115*" ANDS.STREETNAME Not Like "*HWY116*" ANDS.STREETNAME Not Like "*HWY117*" ANDS.STREETNAME Not Like "*HWY118*" ANDS.STREETNAME Not Like "*HWY119*" ANDetc for about 250 more values.AND ((S.TYPE) Is Null));Now, once I get to about 50 of these values or so, I get "query toocomplex", how can I make this happen?TIA 解决方案 On Sat, 21 May 2005 23:07:59 -0700, ynott <yn***@hotmail.com> wrote:Put the values in a table. Then write:SELECT ... WHERE s.StreetName not in (select <FieldName> from<NewTable>)-Tom. Novice here obviously. Anyway, I''m a bit confused about how toapproach this. I have a query against a table that I''m trying tocreate. I''m trying to view all streets.type values that are null, butthen exclude those STREETNAME values that are null for the S.type butthat are really okay. The query goes like:SELECT S.ID, S.ID2, S.PREFIX, S.STREETNAME, S.TYPEFROM streets as SWHERES.STREETNAME Not Like "*HWY110*" ANDS.STREETNAME Not Like "*HWY111*" ANDS.STREETNAME Not Like "*HWY112*" ANDS.STREETNAME Not Like "*HWY113*" ANDS.STREETNAME Not Like "*HWY114*" ANDS.STREETNAME Not Like "*HWY115*" ANDS.STREETNAME Not Like "*HWY116*" ANDS.STREETNAME Not Like "*HWY117*" ANDS.STREETNAME Not Like "*HWY118*" ANDS.STREETNAME Not Like "*HWY119*" ANDetc for about 250 more values.AND ((S.TYPE) Is Null));Now, once I get to about 50 of these values or so, I get "query toocomplex", how can I make this happen?TIA Perfect. ThxOn Sat, 21 May 2005 23:24:29 -0700, Tom van Stiphout<no*************@cox.net> wrote: On Sat, 21 May 2005 23:07:59 -0700, ynott <yn***@hotmail.com> wrote:Put the values in a table. Then write:SELECT ... WHERE s.StreetName not in (select <FieldName> from<NewTable>)-Tom.Novice here obviously. Anyway, I''m a bit confused about how toapproach this. I have a query against a table that I''m trying tocreate. I''m trying to view all streets.type values that are null, butthen exclude those STREETNAME values that are null for the S.type butthat are really okay. The query goes like:SELECT S.ID, S.ID2, S.PREFIX, S.STREETNAME, S.TYPEFROM streets as SWHERES.STREETNAME Not Like "*HWY110*" ANDS.STREETNAME Not Like "*HWY111*" ANDS.STREETNAME Not Like "*HWY112*" ANDS.STREETNAME Not Like "*HWY113*" ANDS.STREETNAME Not Like "*HWY114*" ANDS.STREETNAME Not Like "*HWY115*" ANDS.STREETNAME Not Like "*HWY116*" ANDS.STREETNAME Not Like "*HWY117*" ANDS.STREETNAME Not Like "*HWY118*" ANDS.STREETNAME Not Like "*HWY119*" ANDetc for about 250 more values.AND ((S.TYPE) Is Null));Now, once I get to about 50 of these values or so, I get "query toocomplex", how can I make this happen?TIA TomHave you tried this? Is it slow? I have found "NOT IN" to be very, veryslow. For this reason I would concur with putting the values into atable, but I would suggest using a JOIN in the SQL and a WHERECriteriaTable.StreetName Is Null.But perhaps that idea is no longer relevant and SQL and JET or whateverwill optimize the NOT IN condition so that its execution is fast? 这篇关于查询过于复杂。如何编码不正确的声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 05-26 21:17