php - MySQL query from two tables with multiple joining -
i've 2 tables, example - category & items.
1. category table has 2 fields- cat_id, cat_name. 2. items table has 4 fields field1, field2, field3, field4 value cat_id.
now, need print cat_name
instead of cat_id in each row.
how can that? mysql query?
for more info please, have here- url: http://smartmux.com/demo_roundflat/admin/ username: test password: test
if understood right can this:
select items.*, c1.cat_name, c2.cat_name, c3.cat_name, c4.cat_name items left join category c1 on c1.cat_id = items.field1 left join category c2 on c2.cat_id = items.field1 left join category c3 on c3.cat_id = items.field1 left join category c4 on c4.cat_id = items.field1;
let me know if needed.
Comments
Post a Comment