I have two tables I'm pulling information from.
Lets say table1 has following columns (id, title, category, sub_category, sub_sub_category)
Lets say table2 has following columns (category_id, category_name)
I have a select statement that so far looks as follows:
SELECT
table1.id,
table1.title,
table2.category_name as Cat1,
table2.category_name as Cat2,
table2.category_name as Cat3
FROM
table1,
table2
INNER JOIN table2 as c1 ON c1.category_id = table1.category
INNER JOIN table2 as c2 ON c2.category_id = table1.sub_category
INNER JOIN table2 as c3 ON c3.category_id = table1.sub_sub_category
WHERE
table1.id = ?
This gives me an error about table1.category being an unknown column
I have also tried
SELECT
table1.id,
table1.title,
table2.category_name as Cat1,
table2.category_name as Cat2,
table2.category_name as Cat3
FROM
table1,
table2
WHERE table1.id = ?
AND table1.category = table2.category_id
AND table1.sub_category = table2.category_id
AND table1.sub_sub_category = table2.category_id
The last example at least gives me column output I'm looking for which would be
(table1.id, table1.title, table1.category name, table1.sub_category name...)
So showing the category name from table 2 instead of the ID's. I am an amateur coder and haven't had to use inner joins before but maybe that is what I need to do. I just can't figure out how to get it to output the data I need.
Thank you in advance for your time and consideration.