# Sql and ruby

**URL:** <https://www.ruby-forum.com/t/sql-and-ruby/122630>\
**Category:** Rails\
**Created:** [December 10, 2007, 9:47am UTC](https://www.ruby-forum.com/t/sql-and-ruby/122630 "2007-12-10T09:47:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jojobert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ee7513/32.png) [@jojobert](https://www.ruby-forum.com/u/jojobert)\
**Post date:** [December 10, 2007, 9:47am UTC](https://www.ruby-forum.com/t/sql-and-ruby/122630/1 "2007-12-10T09:47:49Z")

</div>

let me give some background knowledge on my problem

currently:

courses

programmes

degrees

are stored in the database, the app allows people to create courses and  
programmes. Then they are allowed to assign courses and programmes  
together, of course no duplicates allowed. The combinations are stored  
in the degree table.

eg. Records in the degree table

Record 1:  
course code: fg123  
programme code: ha123

Record 2:  
course code: yh123  
programme code: ha123

Record 3:  
course code: ji123  
programme code: kp123

now the problem i have met with is that

i want to allow the user to click on a link, which displays all the  
programme codes, i have grouped them together such that the user will  
see…

Programmes:

-ha123  
-kp123

and when they click on the link itself, the app will be able to display  
all the course codes of courses which has that programme code

eg. when user clicks on ha123

Courses under ha123:

-fg123  
-yh123

can anyone guide me on how to do this without injecting sql statements?
