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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:03:20+00:00 2026-05-27T07:03:20+00:00

I do not know if I awake stupid but I can not solve this

  • 0

I do not know if I awake stupid but I can not solve this :S

I am triying to get items form wp_posts table, joining it with the table wp_postmeta two times (to get to diferent values) and making conditions with this two values.

SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.* FROM wp_posts
INNER JOIN wp_postmeta ds ON (ds.meta_key = 'date_start' AND ds.post_id = wp_posts.ID)
INNER JOIN wp_postmeta de ON (de.meta_key = 'date_end' AND ds.post_id = wp_posts.ID)
WHERE 1 = 1
  AND wp_posts.post_type = 'event'
  AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR wp_posts.post_status = 'private' OR wp_posts.post_status = 'hidden')
  AND CAST(ds.meta_value AS DECIMAL(10,0)) <= 1323043200
  AND (CAST(de.meta_value AS DECIMAL(10,0)) >= 1323129599 OR de.meta_value = '')
ORDER BY ds.meta_value DESC
LIMIT 0, 5

I do not why all columns join with only one row in the 'de' table

I mean:

ID meta_1 post_id meta_2
1     1       1    xxx
2     2       1    xxx
3     3       1    xxx
...

In the condition de.meta_key = 'date_end' AND ds.post_id = wp_posts.ID I am telling the the ID from wp_posts should be equal to post_id from 'de' table (wp_postmeta) but it is not been respected 😐

Any idea of my mistake???

  • 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-27T07:03:20+00:00Added an answer on May 27, 2026 at 7:03 am

    Change

    (de.meta_key = 'date_end' AND ds.post_id = wp_posts.ID)
    --> repeated match of ds.post_id=wp.posts.ID
    

    To

    (de.meta_key = 'date_end' AND de.post_id = wp_posts.ID)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know SysCache uses ASP caching under the hood, but since I'm not aware
I do not know javascript right now but I am planning on learning it.
I faced a little trouble - I do not know if I can define
Somewhere some guy said (I honestly do not know where I got this from),
I am sorry for the title but I really do not know how to
I think this might be a classic question but I am not aware of
I know it could be done using malloc , but I do not know
OK I would like to know this once and for all, how can I
Note: I am not sure if this is better here, or at superuser, but
If you do not know what Pipe Viewer is (I did not know about

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.