Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
in sqlserver have one table using select command to display two tables
Posted
Comments
OriginalGriff 13-Jul-11 14:31pm    
Sorry that is not very clear - do you mean you want to create a new table by merging two others? Or return results from two tables in a single query?
Use the "Improve question" widget to edit your question and provide better information.

this is trusted sql it.

select t1.accode,t2.acname from newchart t1
inner join newchart t2 on t2.id=t1.id

plz check this.
 
Share this answer
 
A table does not use a select command.
Select statements are used to retrieve information from tables.
If you want to select related data from two separate tables then you need to learn how to use a JOIN in your statement. Something like the following is what I am talking about.
SQL
select table1.id,
       table1.value,
       table1.table2_fk,
       table2.value
  from table1
       inner join table2 on table2.id = table1.table2_fk
 
Share this answer
 
You should learn about Join Concept in SQL Server
Take a look at given article which will enable you to learn all type of Join
http://dotnetslackers.com/articles/sql/SQL-SERVER-JOINs.aspx[^]
W3Schools-[SQL Join][^]
 
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