How can I delete inner join and use Left Join instead?
I have two tables that are dishinfo and category,
dishinfo has id_cate which is the number of category
for example:
id_cate:1
id_cate:1
id_cate:2
whereas category table have:
id_cate:1 == cate_descrip:dessert
id_cate:2 == cate_decrip:lunch
my code:
SELECT dishinfo.id_cate,cate_descrip
FROM dishinfo
INNER JOIN category
ON dishinfo.id_cate=category.id_cate;
if you do a simple left join it would be something like:
SELECT dishinfo.id_cate, cate_descrip
FROM dishinfo
LEFT JOIN category
ON dishinfo.id_cate = category.id_cate;
but this will return every records from dishinfo including those that has id_cate NULL to prevent this you can do like this:
SELECT dishinfo.id_cate, cate_descrip
FROM dishinfo
LEFT JOIN category ON dishinfo.id_cate = category.id_cate
WHERE dishinfo.id_cate IS NOT NULL;
with the extra condition you will prevent selecting those records that doesn't have id_cate