Multiple joins

so I am creating a custom checkin/poetry website on top of wordpress.

I need to list all the poetry from users that check in for the night.

I have a table called ‘checkin’ with a field called ID which is the wordpress users id. I also have a filed called date, which is a timestamp.

The poems get stored in the ‘wp0k_posts’ table, The user again is stored as ID. I need to grab of course the ‘post_content’ and ‘post_title’ where the ‘post_type’ is equal to ‘um_story’.

The real difficult part is that wordpress stores the users first name and last name in a separate table called wp0k_usermeta. user_id is equal to wp0k_users.ID. the store the values like so filed “first_name” = “Jim”, “last_name” = “Harris”

I’m hoping to return:
wp0k_users.ID | wp0k_usermeta.first_name | wp0k_usermeta.last_name | wp0k_posts.post_title | wp0k_posts. post_content

Where checkin.date == Today

Haven’t tested it, but this should work…

SELECT um.user_id
     , um.first_name
     , um.last_name
     , p.post_title
     , p.post_content
  FROM checkin c
  JOIN wpok_posts p ON c.user_id  = p.user_id
  JOIN wpok_usermeta um OM um.user_id = c.user_id
 WHERE c.date == CURDATE()
    ,  

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.