I am trying to get a category name form a table(categories) based form a id form another table(stories),
I can kinda do it but it gives me the wrong one because it's in more than one category. here's the two tables with only the fields I need to use and sample data in them.
categories[TABL]
catidparentcatidcategory other fields562Right one 1other datas572Right one 2 other datas60-1Wrong one 1other datas615Wrong one 2other datas[/TABL]
stories[TABL]
sidcatidother fields16060,56other datas[/TABL] all the right categories will have a parentcatid of 2 and none ofthe wrong ones will.I tried doing it like this but I only get no results
SELECT c.category
FROM categories c, stories s
WHERE s.sid =160 AND c.catid IN(s.catid) AND c.parentcatid = 2;
I tried doing it like this but I only get "Wrong one 1"
SELECT c.category
FROM categories c, stories s
WHERE s.sid =160 AND c.catid IN(s.catid);
I'm not really any good at mysql, but is there any why I could do it so it would return "Right one 1"?
thanks alot.