Select in two fields of a table

Asked

Viewed 127 times

0

Hello, I’m going through a problem and I would like to ask for your help. Here’s the thing:

I am integrating a PHP system to the Wordpress Woocommerce plugin and I need to order some products from the database, so far so good. The problem starts when looking for the product in the table. It is like this

Order id              meta_key           value
1                     2                  3
2                     2                  87
3                     3                  45

I need to select id 1 that contains value 3 as long as id 2 contains value 87. How do I do that? I’m completely lost

  • put the table structure, sample data and preferably use Sqlfiddle

  • What is the relationship between ID 1 and ID 2 ?

  • 1

    @Rovannlinhalis none, welcome to weirdpress

  • So this meta_key has no relation? And what are its entries, 3 and 87 same?

  • Actually I want to take the value 3 that has the meta_key of value 2, I mean, I’ll take the value 3 that in the case is the corresponding of 87 that is the id. Imagine like this, 3 is the value of the T-shirt that I will sell in the store and 87 is the product id, so I need to get the value of product 87 using the same key that is common in both, which in this case is number 2

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.