sql >> Base de Datos >  >> RDS >> Mysql

MySQL Inner Join Query Múltiples tablas

Prueba esto:

SELECT 
  p.id,
  p.name,
  l.url,
  o.user_id,
  o.pricing_id
FROM orders AS o
INNER JOIN products_pricing AS pp ON o.pricing_id  = pp.id
INNER JOIN products         AS  p ON pp.product_id = p.id
INNER JOIN listings         AS  l ON l.user_id = o.user_id
WHERE o.user_id ='7' 
  AND l.id = 233 
  AND l.url = 'test.com';

Demostración de SQL Fiddle

Para los datos de muestra que publicó en su pregunta, esto le dará:

| ID |        NAME |      URL | USER_ID | PRICING_ID |
------------------------------------------------------
| 33 | testproduct | test.com |       7 |         37 |