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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:52:58+00:00 2026-05-20T00:52:58+00:00

So I’ve been looking through how to get this to work and haven’t been

  • 0

So I’ve been looking through how to get this to work and haven’t been able to find it, or really even properly search.

I’m looking to join t1 to t2 where I get ALL results from t1, and it’s only joined where t2’s column value is “something”, the table is set up that there are many items in the t2 column. So if t2’s column doesn’t equal “something”, then just have the other data (but mainly I only want ONE of each value for t1 row, because there will be a max of one t2 row that qualifies per t1 row).

select * t1 LEFT JOIN t2 where t2.column="something" AND t1 conditions.

Any help would be appreciated, the tables are WordPress tables, and the thing I’m asked to do would be easier done without WordPress knowing.

—
Actual code attempt:

$ SELECT * FROM posts LEFT JOIN postmeta ON post_id = id WHERE post_status='publish' AND post_type='portfolio' AND meta_key='rjmeta_video'


$Table 1
$ID     Title ....
$----------------------
$5      Some post I need outside of WP

$Table 2
$meta_id  post_id   meta_key  ....
$--------------------------------
$3        5         rjmeta_video
$4        5         _edit_lock
$5        5         _edit_last
  • 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-20T00:52:59+00:00Added an answer on May 20, 2026 at 12:52 am

    I believe this is what you mean:

    select distinct t1.* from t1 
    LEFT JOIN t2 on [condition for join] and t2.column="something" 
    where [t1 conditions].
    

    This assumes that you are only interested in the t1 fields.

    What we don’t know:

    • table schemas
      • how are they joined? t2.t1_id = t1.id ?
    • t1 conditions

    DISTINCT used above will eliminate duplicate rows if there are multiple matches for the join

    EDIT (OP comment response):

    SELECT distinct posts.* FROM posts 
    LEFT JOIN postmeta ON (post_id = id and meta_key='rjmeta_video')
    WHERE post_status='publish' AND post_type='portfolio'
    

    This assumes that ‘rjmeta_video’ is the “something” you were referring to originally

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I need to write an AS3 program to search for a certain keyword in
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.