Skip to content
Advertisement

how i get my 2nd id in the join table in mysql

SELECT package.pkg_name, pkg.cat_id,pkg.id
FROM pkg
INNER JOIN package ON pkg.id=package.id
join categories ON pkg.cat_id=1=categories.cat_id=1

1st id is show in join table but 2nd id does not show in the join table

Advertisement

Answer

If you are trying to select records where categories id equals to 1. This should work:

SELECT package.pkg_name, pkg.cat_id, pkg.id
FROM pkg
INNER JOIN package ON pkg.id = package.id
JOIN categories ON pkg.cat_id = categories.cat_id
WHERE categories.cat_id = 1;

This joins all 3 tables together + shows you the record where categories.cat_id = 1

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement