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

  • Home
  • SEARCH
  • 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 6213027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:37:17+00:00 2026-05-24T06:37:17+00:00

I need help with a complicated query. I have a Venues table, a Tag

  • 0

I need help with a complicated query. I have a Venues table, a Tag table and a Venues_Tag_lookup table. When I have the detail of a single venue on screen I would like to be able to show other venues that are similar to the current venue.

This will require a query that returns the top 5 venues with the most amount of matching tags. (I’m using MSSQL)

Here is a simple layout of how my tables look.

Venues_tbl
----------
VenueId
Venue_name

Tag_tbl
---------
TagId
Tag_name

Venues_Tag_lookup
------------------
Venue_tagId
VenueId
TagId

If you have any question please ask.

Thanks in advance.

  • 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-24T06:37:19+00:00Added an answer on May 24, 2026 at 6:37 am
    SELECT TOP 5
       V.Venue_name
    FROM
       -- this = tags for this venue
       Venues_Tag_lookup this
       JOIN
       -- others = tags for other venues
       Venues_Tag_lookup others
                --see what matches, there will be a big pile of them
                ON this.TagId = others.TagId
       JOIN
       Venues_tbl V ON others.VenueID = V.VenueID
    WHERE
       --filter to this and others
       this.VenueID = @TheOneOnScreen
       AND
       others.VenueID <> @TheOneOnScreen
    GROUP BY
       --collapse to other venues ...
       V.Venue_name
    ORDER BY
       -- ... and simply COUNT matches
       COUNT(*) DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a help with a complicated select query.I have message table CREATE TABLE
Hi Need help to resolve some complicated query. I'll send the input username (say
I have been thinking about a complicated view/query I need to create but I
I need help understanding some C++ operator overload statements. The class is declared like
i need help with disk_total_space function.. i have this on my code <?php $sql=select
I have a make table query that is used to run a report (due
I was hoping someone could help with a complicated date range SQL query. I
I have a particularly complicated query for a report. It selects several columns from
The last query I need help with is for a specific reservation show the
just need help with regular expression in mysql query please: column ISRC GBCQV0700378 GBCQV0700382

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.