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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:34:51+00:00 2026-06-12T06:34:51+00:00

I have two tables word_term_relationships and word_posts What I’m doing is using a while

  • 0

I have two tables word_term_relationships and word_posts

What I’m doing is using a while loop in order to fetch a certain record from the word_term_relationships table where a certain value is true.

$query = "SELECT object_id 
          FROM `word_term_relationships` 
          WHERE `term_taxonomy_id` = '54'"; 

I then use another query within the loop to use the data that was retrieved from the previous query in order to fetch data from the other table word_posts

$query2 = "SELECT post_title, post_date, post_date_gmt, guid 
           FROM `word_posts` 
           WHERE `ID` = '$post_id'";

This I can do and works fine.

The only issue is that I then need to order the results by date and time, I can do this without the while loop and using the ORDER BY function and the word_posts table.

However, I’ve tried to link the tables within the query like this (below) in order to order the data. But obviously it isn’t correct – I just can’t pinpoint within the query what is wrong.

$query = "SELECT word_term_relationships.object_id 
          FROM word_term_relationships 
          WHERE word_term_relationships.term_taxonomy_id = '54' 
          ORDER BY word_posts.post_date ASC";

I know the above query is missing something, I was thinking a second where after the ORDER BY word_posts.post_date ASC.

  • 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-12T06:34:52+00:00Added an answer on June 12, 2026 at 6:34 am

    A simple INNER JOIN will solve your problem. Try this,

    SELECT a.post_title, 
           a.post_date, 
           a.post_date_gmt, 
           a.guid 
    FROM   word_posts a 
           INNER JOIN word_term_relationships b
               ON a.ID = b.object_id
    WHERE  b.term_taxonomy_id= '54'
    ORDER BY a.post_date ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to search across multiple columns from two tables in my database using
I have two tables images2 and image_data So the goal is to have 1
I have two tables 1.Products prod_id prod_name 1 honda 2 hero 3 marcedes 4
I have two tables, lets say table1 and table2 with common columns, id and
I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables, activities and activity_tours . activities hasMany activity_tours and are related
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables user table user_id | name | 1 | peter |
I have two tables, a user table and a application table: User id username
I have two tables in my MySQL database, one is a library of all

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.