[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.2

Error: Query is too complex.

Asked by Pellanor in Microsoft Access Database

Tags: too, like, query

Okay, I've done some research on the "Query is too complex error", and found out that it's usually caused in ADO when trying to update large numbers of fields at a time.

However, I'm just doing a select, not an update, and the SQL I'm using is going into a List Box's row source.

Here's what I'm doing:
I have a search form, where the user can enter in a search phrase.
This form contains a number of features:
- text box for search string, search button, and other stuff like that
- an option group(frmSearchType) to select if it is to search All Words(returns 1), Any Words(2), or Exact Phrase(3) (by the way, what is the proper naming convention for option groups?)
- an option group(frmAppearsIn) to select which fields we wish to select (Any Checked(1), All Checked(2), None Checked(3))
- 14 checkboxes, each one represents one of the possible searchable fields. The Tag value for each of these check boxes is set to the name of the field that is to be searched.

I have code that automatically generates the where statment for the sql, based on the input in the above form at the time that the submit button is clicked. The SELECT ... FROM ... is hard coded, as is the ORDER BY ...

the sql code that is generated looks like this:

(all 14 checkboxes are checked, searching for All words in Any Selected, search string is "foo bar")
SELECT ... FROM ... WHERE 0
OR ( 1
  AND (nd.device_name LIKE 'foo' OR nd.device_name LIKE '*foo' OR nd.device_name LIKE 'foo*' OR nd.device_name LIKE '*foo*')
  AND (nd.device_name LIKE 'bar' OR nd.device_name LIKE '*bar' OR nd.device_name LIKE 'bar*' OR nd.device_name LIKE '*bar*')
)
OR ( 1
  AND (dt.name LIKE 'foo' OR dt.name LIKE '*foo' OR dt.name LIKE 'foo*' OR dt.name LIKE '*foo*')
  AND (dt.name LIKE 'bar' OR dt.name LIKE '*bar' OR dt.name LIKE 'bar*' OR dt.name LIKE '*bar*')
)
// 11 more OR statements are here.
OR ( 1
  AND (nd.manage_now_resource_id LIKE 'foo' OR nd.manage_now_resource_id LIKE '*foo' OR nd.manage_now_resource_id LIKE 'foo*' OR nd.manage_now_resource_id LIKE '*foo*')
  AND (nd.manage_now_resource_id LIKE 'bar' OR nd.manage_now_resource_id LIKE '*bar' OR nd.manage_now_resource_id LIKE 'bar*' OR nd.manage_now_resource_id LIKE '*bar*')
) ORDER BY s.name, nd.device_name

That works.

However when I search for ANY words instead of ALL words, we get the following sql:
SELECT ... FROM ... WHERE 0
OR ( 0
  OR (nd.device_name LIKE 'foo' OR nd.device_name LIKE '*foo' OR nd.device_name LIKE 'foo*' OR nd.device_name LIKE '*foo*')
  OR (nd.device_name LIKE 'bar' OR nd.device_name LIKE '*bar' OR nd.device_name LIKE 'bar*' OR nd.device_name LIKE '*bar*')
)
OR ( 0
  OR (dt.name LIKE 'foo' OR dt.name LIKE '*foo' OR dt.name LIKE 'foo*' OR dt.name LIKE '*foo*')
  OR (dt.name LIKE 'bar' OR dt.name LIKE '*bar' OR dt.name LIKE 'bar*' OR dt.name LIKE '*bar*')
)
// 11 more OR statements are here.
OR ( 0
  OR (nd.manage_now_resource_id LIKE 'foo' OR nd.manage_now_resource_id LIKE '*foo' OR nd.manage_now_resource_id LIKE 'foo*' OR nd.manage_now_resource_id LIKE '*foo*')
  OR (nd.manage_now_resource_id LIKE 'bar' OR nd.manage_now_resource_id LIKE '*bar' OR nd.manage_now_resource_id LIKE 'bar*' OR nd.manage_now_resource_id LIKE '*bar*')
) ORDER BY s.name, nd.device_name

I get no results for the above sql statement, and when I copy and paste the full SQL into a query I get the "Query is too Complex" error.

As the sql is dynamically generated there's the possibilty for it to become even more complex (if, for example, the search string is 5 words, instead of only 2, or more searchable fields are later added).

If anybody has any idea on what I could do to simplify the sql here, so I don't get that error, it would be much appreciated.

If you want to see any more of my code, just ask.
[+][-]11/25/04 03:01 PM, ID: 12677598Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Microsoft Access Database
Tags: too, like, query
Sign Up Now!
Solution Provided By: ChrisFretwell
Participating Experts: 1
Solution Grade: A
 
[+][-]11/25/04 03:04 PM, ID: 12677610Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/25/04 03:09 PM, ID: 12677626Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/25/04 03:10 PM, ID: 12677628Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/25/04 03:19 PM, ID: 12677663Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/25/04 03:21 PM, ID: 12677673Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/25/04 03:22 PM, ID: 12677675Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/25/04 03:27 PM, ID: 12677699Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/25/04 03:27 PM, ID: 12677700Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/26/04 07:56 AM, ID: 12681766Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/26/04 08:43 AM, ID: 12682085Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/26/04 09:05 AM, ID: 12682203Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/26/04 09:06 AM, ID: 12682212Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/26/04 09:15 AM, ID: 12682271Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/26/04 11:43 AM, ID: 12682974Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89