Jump to content

[SOLVED] I know it's a typo - can someone help me with this?


TechMistress

Recommended Posts

Hello Everyone,

 

I've got a snippet of code that is not resulting in what I want.

 

I have 2 tables.

table 1 is projects, holds project info and project_types (category ids)

table 2 is categories, hold category ids and category names

 

My snippet of code here is showing the category/project_type id instead of the category_name. What did I do wrong?

 

SELECT p.project_types, c.cat_name FROM projects p LEFT JOIN categories c ON p.project_types = c.cat_id GROUP BY p.project_types ORDER BY c.cat_name ASC

Hmm, I don't think I explained well.

 

the project_type in TABLE "projects" is the same as cat_id in TABLE "categories". (don't ask me why it's labeled differently)

 

I want to display the "cat_name" from TABLE "categories" who's "cat_id" matches the "project_type" of TABLE projects.

 

I hope that's clearer. (hopefully not worse)

No, no arrays. It turns out the code worked fine - the problem was with my data. The categories were re-done, so the project_type id was a number that was no longer matching any cat_id from the other table, so I just saw the number.

 

Thanks everyone for the comments!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.