two tables, 1 has the names and 1 has the ids
Categories
cat_id | cat_name
1 good
2 bad
3 ugly
Marks
mark_count | cat_id
10 1
20 1
30 3
What i have problems getting at is having the name of the category associated with the cat_id to be printed out for each item in the Marks table. So the mark 10 => good, mark 20 => good , mark 30 => ugly. Any help would be appreciated
6 Replies - 813 Views - Last Post: 24 July 2012 - 11:52 AM
#1
Task to include the id from one table to get the name listed in anothe
Posted 24 July 2012 - 10:08 AM
Replies To: Task to include the id from one table to get the name listed in anothe
#2
Re: Task to include the id from one table to get the name listed in anothe
Posted 24 July 2012 - 10:14 AM
try
(select cat_name from Categories inner join Marks on Categories.cat_id = Marks.cat_id)
This post has been edited by DarenR: 24 July 2012 - 10:14 AM
#3
Re: Task to include the id from one table to get the name listed in anothe
Posted 24 July 2012 - 10:19 AM
I will try that right now, thanks for the tip so far
#4
Re: Task to include the id from one table to get the name listed in anothe
Posted 24 July 2012 - 10:27 AM
It works but it only prints out the category names, i was looking to print the category name and marks
#5
Re: Task to include the id from one table to get the name listed in anothe
Posted 24 July 2012 - 10:29 AM
np add
(select cat_name, Marks.mark_count from Categories inner join Marks on Categories.cat_id = Marks.cat_id)
#6
Re: Task to include the id from one table to get the name listed in anothe
Posted 24 July 2012 - 10:43 AM
Thanks for helping me, that did the trick. I had started it but i ended up doing a whole lot of code that was not needed, this much more stream lined.
#7
Re: Task to include the id from one table to get the name listed in anothe
Posted 24 July 2012 - 11:52 AM
no problem
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|