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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:48:00+00:00 2026-05-22T23:48:00+00:00

What I am trying to do is get the results from the first query

  • 0

What I am trying to do is get the results from the first query pass them into an array and then use them in a sub query. Both queries work separately if I input the id’s into the sub query manually. Is there a way of linking these two queries?

I have used this code

$result = mysql_query("SELECT v2.video_id as v2id FROM VideoTags AS v1 JOIN VideoTags AS v2 USING ( tag_id ) WHERE v1.video_id =1 AND v1.video_id <> v2.video_id GROUP BY v2.video_id ORDER BY COUNT( * ) DESC"); 

$values = array();

while ($row = mysql_fetch_array( $result )) {
  $values[] = $row['v2id'];
}

echo join(", ", $values);

$resultone = mysql_query("SELECT * FROM videos WHERE video_id IN (' . join(',', $values). ')"); 

while ($row = mysql_fetch_array( $resultone )) {
  echo "name ".$row['video_name'];
}

Thanks for your help.

  • 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-22T23:48:01+00:00Added an answer on May 22, 2026 at 11:48 pm

    Yes, it’s called subquery (and what you use is not subquery, because it does not contain one query inside another.

    SELECT * 
    FROM videos 
    WHERE video_id IN (
        SELECT v2.video_id 
        FROM VideoTags AS v1 
        JOIN VideoTags AS v2 USING ( tag_id ) 
        WHERE v1.video_id =1 AND v1.video_id <> v2.video_id 
        GROUP BY v2.video_id ORDER BY COUNT( * ) DESC
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use $.post within a function, get the results, then return the
I'm trying to get the AVERAGE from the results of two separate sql queries
I'm trying to build up a string array in JavaScript and get the results
I'm trying to use the jQuery get function to render the results of an
I'm trying to turn some query results into click-able links through PHP. I'm a
I am trying to use specific numeric results from a mysql_fetch_array within a while
I'm trying to get the following query to work in Hibernate: SELECT m FROM
I am running MongoDB in the REST mode and trying to get query results
In WPF app I use LINQ query to get values from ObservableCollection and update
I'm trying to get distinct results using the Criteria API in NHibernate. I know

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.