Click here to Skip to main content
16,005,552 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi....i am a newbee to sql....can someone guide me ....my requirement is i have a main table in sql and it contains a field by name Head which is an integer..the main tables contains the Head IDs(integer)...and also the head ids in the main table comes from the Head table which contains Head_id(int),HeadName(varchar).....my question is how to write a sql query to retreive the Corresponding headnames in the Main table from the HEAD table........so that headnames can be displayed on a grid but not head_ids..
thanks
Posted

Use select [coluumn1]. [column2] from [tablename] where column1, column2 etc are your field names and [tablename] is your tablename.
 
Share this answer
 
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;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900