I don't understand fully what you mean but :
you've two tables, first called "Main" and other called "Head"?
how to write a sql query to retreive the Corresponding headnames in the Main table from the HEAD table
for this you need to use "join" you can read more
http://www.w3schools.com/sql/sql_join.asp
or you try this simple:
select h.HeadName from Main m, Head h where h.id = m.Head_id;