Posted in

Consulta MySQL a múltiples tablas

Un ejemplo de como realizar una consulta a diferentes tablas usando LEFT JOIN.

SELECT a.`id_product` AS id_product, e.`id_owner`, i.latitude, i.longitude, i.id_sellerinfo, o.company
oFROM `' . _DB_PREFIX_ . 'megaproductslotproduct` AS a
oLEFT JOIN `' . _DB_PREFIX_ . 'product_owner` e ON e.id_product = a.id_product
oLEFT JOIN `' . _DB_PREFIX_ . 'sellerinfo` i ON i.id_seller = e.id_owner
oLEFT JOIN `' . _DB_PREFIX_ . 'sellerinfo_lang` o ON o.id_sellerinfo = i.id_sellerinfo AND id_lang = 1
oWHERE ' . $sWhere . ' GROUP BY id_product'

Deixa un comentari

L'adreça electrònica no es publicarà. Els camps necessaris estan marcats amb *


The reCAPTCHA verification period has expired. Please reload the page.