Solved

Querying a Query for Search Panel

Posted on 2014-11-26
4
82 Views
Last Modified: 2014-12-24
I don't even know what to "search" under on google to find the answer. I've tried a few things and the results don't have anything like I'm looking for, so I'll ask here.

You know those car dealership websites where they have you search for cars and then on the left is a search panel with a bunch of checkboxes. It shows there are:
Fords (22)
Hondas (13)

Then you can click just Hondas and it gets rid of the Fords and shows only the Hondas. And same with models, colors, etc. etc.

That's the type of search I want to do.

How does one do the query involved in that? Are they creating a main sql and using some kind of dataset and searching within that dataset? Or what exactly is happening with the query and data behind the scenes?

I don't need to know how to ajax the boxes and such, just how to handle that query. Those sites are pretty fast when returning data and I'd like to use best practices on this and not try to figure out what I think is going on. If you don't know, please don't respond, I'd prefer not to get guesses and would like an answer from someone who knows how to do it for certain.

thanks!
0
Comment
Question by:Starr Duskk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 200 total points
ID: 40467356
It's essentially a GROUP BY that goes something like this:

SELECT MakeName, COUNT(Make) as the_count
FROM YourTable
WHERE -- whatever the user selects
GROUP BY MakeName

Open in new window


Then if the user clicks on one it'll show the details like this:
SELECT yabba, dabba, doo
FROM cars
WHERE MakeName='{whatever the user clicked on}'

Open in new window

For a frienly tutorial on grouping visit SQL Server GROUP BY Solutions
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 40469328
I understand grouping, I guess I just thought as quick as those search panels come up and when the user clicks the checkboxes the results come up quickly, I thought maybe there was something quick going on. Like maybe you start with a dataset of everything, and then you query against the dataset or something.

I can do all of the above individually as queries, I just figured there was some magic I was missing to make it streamlined and quick. So nothing special is going on?

Every single checkbox group is queried for the search panel for the count?
then when you click a checkbox every single click rebuilds the query and displays the results?
and so on?

that part is easy to do. But it just seems so tedious to hit the database that many times so I thought something else might be going on that I didn't know about.

thanks!
0
 
LVL 8

Accepted Solution

by:
Ashutosh Vyas earned 300 total points
ID: 40475339
Load all your data at the beginning into a DataTable and put that Datatable as the source for your gridview (I am assuming you are displaying your data in the gridview).

When the checkboxes are checked, construct the filters for datatable and rebind.
Something like

   
 dt.DefaultView.RowFilter = "MakeName= '" + filterText + "'";
    gvList.DataSource = dt.DefaultView;
    gvList.DataBind();

Open in new window

0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 40477867
Ashutosh,

thanks! that's more in line with what I thought might be happening. I'll try it out within the next week or so and let you know if I have further questions. thanks so much!
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
grouping by date only 6 22
Run software updates from the website 6 50
ASP.NET, Globalization, language indexes, translation, conversion. 2 67
HIghlights of SSIS? 3 44
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question