6 Replies - 923 Views - Last Post: 24 July 2012 - 11:52 AM

#1 kabuto178  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 130
  • Joined: 29-January 11

Task to include the id from one table to get the name listed in anothe

Posted 24 July 2012 - 10:08 AM

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

Is This A Good Question/Topic? 0
  • +

Replies To: Task to include the id from one table to get the name listed in anothe

#2 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 434
  • View blog
  • Posts: 3,013
  • Joined: 12-January 10

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

Was This Post Helpful? 0
  • +
  • -

#3 kabuto178  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 130
  • Joined: 29-January 11

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
Was This Post Helpful? 0
  • +
  • -

#4 kabuto178  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 130
  • Joined: 29-January 11

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
Was This Post Helpful? 0
  • +
  • -

#5 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 434
  • View blog
  • Posts: 3,013
  • Joined: 12-January 10

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) 

Was This Post Helpful? 0
  • +
  • -

#6 kabuto178  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 130
  • Joined: 29-January 11

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.
Was This Post Helpful? 0
  • +
  • -

#7 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 434
  • View blog
  • Posts: 3,013
  • Joined: 12-January 10

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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1