Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 i want records from two tables

Author  Topic 

asifbhura
Posting Yak Master

165 Posts

Posted - 2010-04-10 : 10:28:05
Hi,

I have two tables such as ticket and customer,

in customer table i have these fields such mobileno,customerName,Addrss,Id etc....
ID column is autogenerated(IDENTITY)

In, ticket table,I have these fields,
id,cust_id,ticket_detail,createdDate etc....
here also ID is autogenerated,

Now, there can be more than one ticket for one customer

I need query like,

I want all tickets records with customerName and mobileno.

means it must take from cust_id in ticket table

means i want result like this

id,cust_id,ticket_details,customer name,mobileno


Regards,
ASIF

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-04-10 : 11:11:29
Try this:

Select T.ID, C.id as Cust_id, T.ticket_detail , C.customerName,
C.mobileno
from ticket_table t inner join Customer_table C on C.Id = T.Cust_id

Regards,
Bohra
Go to Top of Page
   

- Advertisement -