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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:02:49+00:00 2026-06-15T10:02:49+00:00

I want to making a MySQL query that gets a link from table1 and

  • 0

I want to making a MySQL query that gets a link from table1 and checks to see if this link exists in table2 and table3.

Now I am doing 2 queries, but I would like to combine the 2 query into 1, and guarantee 10 results are returned? (After the first, currently, if mysql_num_rows($rez)>0, the return result would be less 10)

Thanks.

$result = mysql_query("SELECT id,link FROM table1 WHERE Order By id DESC LIMIT 0,10"); 
while ($row = mysql_fetch_array($result)){
  $rez = mysql_query("(SELECT link FROM table2 WHERE link='".mysql_real_escape_string($row['link'])."') UNION (SELECT link FROM table3 WHERE link='".mysql_real_escape_string($row['link'])."')");
  if(mysql_num_rows($rez)==0){
    //do stuff with $row['link'];
  }
}
  • 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-06-15T10:02:51+00:00Added an answer on June 15, 2026 at 10:02 am

    You can use sub-queries to acomplish this

    SELECT id, link FROM table1 WHERE (link IN (SELECT link FROM table2)) OR (link IN (SELECT link FROM table3)) LIMIT 10

    My format might be slightly off, and it seems like there’s probably a better way to do that query, but check out sub-queries as I think those will get you in the direction you want to go

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

Sidebar

Related Questions

What i want is that making an div toggle. Visible it or not. this
I'm working with a MySQL query that writes into an outfile. I run this
For this exercise I'm making I want a decimal < 4096 to be written
Debugging experience http://www.dmhermitage.org/wtfborders.png This is making me want to kill myself. I have some
I want help on this script I am making... I want my website to
The problem is this.I want to save every message in MySQL DB and I
i see a couple of questions on here and elsewhere that address this in
I have this query: SELECT p.text,se.name,s.sub_name,SUM((p.volume / (SELECT SUM(p.volume) FROM phrase p WHERE p.volume
Say I want to check if a record in a MySQL table exists. I'd
I'm making a quotes and phrases site. I want to post this quotes and

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.