Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 364631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:27:26+00:00 2026-05-12T13:27:26+00:00

Would really appreciate some help with a search angine I’m trying to make for

  • 0

Would really appreciate some help with a search angine I’m trying to make for a karaoke music site using ASP.NET and SQL SERVER…

I have a table called Discs which has the following fields:

ID, DiscCode, DiscTitle, DiscType,
Theme, Manufacturer

There is also a table called Tracks with the following fields

ID, DiscID, Artist, Title

OK, so imagine a user performs a search for the following…

Artist: Michael Jackson
Title: Thriller
Theme: Pop
Manufacturer: Sunfly
DiscType: cdg

I would use a SQL statement like this….

SELECT D.ID, T.Artist, T.Title, D.Manufacturer, D.DiscTitle 
FROM Discs D
INNER JOIN Tracks T
ON T.DiscID = D.ID 
WHERE T.Artist LIKE 'Michael JAckson%' 
AND T.Title LIKE 'Thriller%' 
AND D.Theme = 'Pop' 
AND D.Manufacturer = 'Sunfly' 
AND DiscType = 'DVD';

That will work fine, but if no results are found I really want to be able to tell the user how many results they would get if any of the filters were removed with a count, like ebay does…

Sorry, No results were found but we did find some similar results.

Different Artists (13)

Different Manufacturers (4)

Different Themes (2)

The client has 2 stipulations for us. A) he wants to use a “startswith” match on each item, hence the wildcard at the end of each LIKE , and B) he doesn’t want to use MSSQL Full TEXT searching.

I don’t want to have to do lots of searches as this will really slow things down and instinctively it feels like there should be some way of doing this by using crouping and counts.

Any help would really be appreciated.

Jon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:27:26+00:00Added an answer on May 12, 2026 at 1:27 pm
    SELECT  SUM(CASE WHEN cnt = 3 THEN 1 ELSE 0 END) AS exact_matches,
            SUM(CASE WHEN artist LIKE 'Michael Jackson%' THEN 0 ELSE 1 END) AS diff_artist,
            SUM(CASE WHEN theme = 'Pop' THEN 0 ELSE 1 END) AS diff_theme,
            SUM(CASE WHEN manufacturer = 'Sunfly' THEN 0 ELSE 1 END) AS diff_manufacturer
    FROM    (
            SELECT  t.id, COUNT(*)  AS cnt
            FROM    (
                    SELECT  t.id
                    FROM    tracks t
                    JOIN    discs d
                    ON      t.discID = d.id
                    WHERE   t.artist LIKE 'Michael Jackson%'
                    UNION ALL
                    SELECT  t.id
                    FROM    tracks t
                    JOIN    discs d
                    ON      t.discID = d.id
                    WHERE   d.theme  = 'Pop'
                    UNION ALL
                    SELECT  t.id
                    FROM    tracks t
                    JOIN    discs d
                    ON      t.discID = d.id
                    WHERE   d.manufacturer = 'Sunfly'
                    ) q
            GROUP BY
                    t.id
            HAVING  COUNT(*) >= 2
            ) q2
    JOIN    table t
    ON      t.id = q2.id
    JOIN    discs d
    ON      d.id = t.discID
    

    This is index friendly, since it runs three separate queries, each on them using its very own plan.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would really appreciate it if some of you could help optimize my tables,
I am struggling to solve a problem and would really appreciate some help. public
I would really appreciate some help with my problem: I have 2 MySQL tables,
I am new to Ruby and would really appreciate some help understanding what is
I'm fairly new to SQL Server and would really appreciate some help with this.
I'm totally stumped on this error. Would really appreciate some help :). To reproduce
I'm having a problem loading my xml file using simplexml_load_file(), would really appreciate some
Ok, im pretty new at this and I would really appreciate some help, thanks!
I'm still learning CSS and page formatting and stuck. Would really appreciate some help.
I would really appreciate some help with the following issue: I have a gadget

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.