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 6353007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:20:04+00:00 2026-05-24T22:20:04+00:00

I am trying to do an sql query or set of queries that will

  • 0

I am trying to do an sql query or set of queries that will allow me to find other videos that have the same tags and order them by the most number of matches. I am using php as a server side code and mysql as my database. For this I am using 2 tables.

video

  Column    Type           Null 
     timestamp  int(11)     No       
     vid_id     varchar(32) No       
     file_name  varchar(32) No       
     uploader   varchar(55) No       
     title      varchar(30) No       
     duration   varchar(7)  No       

    Keyname Type     Unique Packed  Column  Cardinality Collation
    vid_id  BTREE    Yes    No      vid_id         94       A       
    title   FULLTEXT No     No       title              0

tags

 Column      Type      Null 
     id     varchar(35) No       
     vid_id varchar(35) No       
     name   varchar(15) No       

    Keyname Type    Unique  Packed  Column  Cardinality Collation
    vid_id  BTREE   Yes      No     vid_id      0      A        
    name    FULLTEXT No      No     name        0

One vid_id will be supplied for the query. I really am not sure what the best way to approach this would be so any expert opinion would really be appreciated.

  • 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-24T22:20:05+00:00Added an answer on May 24, 2026 at 10:20 pm

    I would do a

    SELECT vid_id, COUNT(*) as count 
       FROM tags 
       WHERE name IN('list','of','videos','tags') 
       GROUP BY vid_id
       ORDER BY count DESC
    

    If you choose to employ the method in my comment above, this would be slightly more complicated.

    You would need first

    SELECT id FROM tags WHERE name IN('list','of','video','tags')
    

    then, using those tag ids

    SELECT vid_id, COUNT(*) as count
       FROM tags_videos
       WHERE tag_id IN(list,of,tag,ids)
       GROUP BY vid_id
       ORDER BY count DESC
    

    You could probably still do it in one query, but it would use some ugly joins, and the speed difference probably wouldn’t be TOO significant.

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

Sidebar

Related Questions

I have a SQL query that I'm currently solving by doing two queries. I
I have a class that needs a property set inside a LINQ-to-SQL query. My
I'm trying to run a LINQ to SQL query that returns a result in
I'm trying to write an SQL query that would search within a CSV (or
I am trying to learn SQL query optimization using SQL Server 2005. However, I
When trying to enter a SQL query with parameters using the Oracle OLE DB
I'm trying to perform a SQL query through a linked SSAS server. The initial
I'm trying to convert the below SQL query to HQL and am having a
I am trying to execute this SQL query prior to restoring a .BAK file
I'm trying to create an SQL query in PHP to update a table. Is

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.