“Not unique table/alias” in MySQL

You are joining the same table 2 times and hence you need to provide the unique alias name. However looks like you are looking for parts table and hence need to join that table

SELECT 
categories.name, 
categories.sub_name, 
parts.name
FROM categories
INNER JOIN presentations ON categories.id=presentations.category
INNER JOIN parts ON parts.id=presentations.parts
WHERE presentations.id=5;

For better readability you can always give some short alias name something as

select
c.name,
c.sub_name,
p.name as parts_name
from categories c
join presentations pr on pr.category = c.id
join parts p on p.id = pr.parts
where pr.id = 5

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)