i have a problem with a query, for example with this one i can retrieve the records:
SELECT
l.*,
ll.f_cocacola as cocacola,
le.name AS deposit,
lp.price
FROM
KPC AS l,
KPC_cocacola AS ll,
KPC_deposit AS le,
KPC_price AS lp
WHERE
l.cod_deposit = le.id_deposit
AND l.code = ll.code
AND lp.code = l.code
AND l.code_deposit = '002365'
but now i need to include another date from another table -intranet- that has the fields code and url then need to show from this table the url field .. keep in mind that the relationship is on the code field.
so i change the query in this way:
SELECT l.*,ll.f_cocacola as cocacola, le.name AS deposit,
lp.price, lintranet.url
FROM tableX AS l, intranet_cocacola AS ll, tableX_deposit AS le,
tableX_price AS lp,
tableX_intranet as lintranet
WHERE l.code_deposit = le.id_deposit
AND l.code = ll.code
AND lp.code = l.code
AND l.code = lintranet.code
AND l.code_deposit = '456852147'
but the issue is that some records don’t have a url and if is not exist a url then this query don’t show me the record .. well what i need that even if there is not a url associated to a record i want to see that recorda, thanks
Rewrite your query using ANSI join syntax and use
LEFT JOIN: