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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:54:28+00:00 2026-06-02T03:54:28+00:00

Revised. My SQL is limited, so really appreciate your help. In one hit, I

  • 0

Revised. My SQL is limited, so really appreciate your help. In one hit, I want to query by ID ($ga_id) two tables each with an inner join to another table (tables have exactly the same columns and the parent tables have no relationship to each other).

I can successfully query the net_5_postmeta table as follows

SELECT p.*
FROM net_5_postmeta AS pm
INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID 
WHERE pm.post_id = $ga_id
AND pm.meta_key = '_thumbnail_id' 
ORDER BY p.post_date DESC 
LIMIT 4

but I want to query the net_5_postmeta table and the net_7_postmeta table (they have the same columns), I think it needs to be something along the lines of…

SELECT p.*
FROM net_5_postmeta, net_7_postmeta AS pm
INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID
INNER JOIN net_7_posts AS p ON pm.meta_value=p.ID 
WHERE pm.post_id = $ga_id
AND pm.meta_key = '_thumbnail_id' 
ORDER BY p.post_date DESC 
LIMIT 4
  • 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-02T03:54:30+00:00Added an answer on June 2, 2026 at 3:54 am

    As you say that parent tables have no relationship i can only assume that you want to treat 5 and 7 tables as if they were the same. You should use union all to bring their data together and then do ORDER BY/LIMIT.

    SELECT *
    FROM
    (
      SELECT p.*
      FROM net_5_postmeta AS pm
      INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID 
      WHERE pm.post_id = $ga_id
      AND pm.meta_key = '_thumbnail_id' 
    
      UNION ALL
    
      SELECT p.*
      FROM net_7_postmeta AS pm
      INNER JOIN net_7_posts AS p ON pm.meta_value=p.ID 
      WHERE pm.post_id = $ga_id
      AND pm.meta_key = '_thumbnail_id' 
    ) united
    ORDER BY united.post_date DESC 
    LIMIT 4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a LINQ to SQL query and am really stumped.
* revised, but still not solved...* I want to combine data from two files
-- All of the revised code still refuses to run well, please help --
Revised Query.. the [Id] column is unique to all records.. the query should return
REVISED: Okay, thanks to all of your input, I figured out what I was
Revised: The problem is to paint a four sided border where each side starts
This SQL query was generated by Microsoft Access 2003, and works fine when run,
Revised Code jQuery(function($) { $(#filter).keyup(function () { var filter = $(this).val(), count = 0;
REVISED QUESTION : We have tracked this down to a custom add to cart
EDIT: my revised Entity relationship diagram A Student can have many contact times but

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.