| Author |
Topic |
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2010-04-06 : 15:35:55
|
| hi,this is my query and it shows all records twiceSELECT t.id,t.ticket_no,t.customer_id,t.location,t.distributor,t.date_of_buy ,t.ticket_status,c.mobile FROM dbo.ticket_details t left join customer_details c on t.customer_id = c.id WHERE t.createdDate < DATEADD(HH,-48,getdate()) ORDER BY t.id DESCplease help me REgards,ASIF |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2010-04-06 : 15:46:24
|
| Sorry tara,I didnt get you, can you write a query for me,Regards,ASIF |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-06 : 15:56:32
|
| [code]SELECT * FROM dbo.ticket_details t LEFT JOIN customer_details c ON t.customer_id = c.id WHERE t.createdDate < DATEADD(HH,-48,getdate()) ORDER BY t.id DESC[/code]That won't stop each record displaying twice, but it will give you an idea as to why it's happening.There are 10 types of people in the world, those that understand binary, and those that don't. |
 |
|
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2010-04-06 : 15:57:36
|
| Hi Tara,So, how can i fix this onewhy it gives two recordsRegards,ASIF |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-06 : 16:07:47
|
| What are the primary keys of the ticket_details and customer_details tables?There are 10 types of people in the world, those that understand binary, and those that don't. |
 |
|
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2010-04-06 : 16:47:18
|
| 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 customerI need query like,display all tickets with customer mobileno and customernamemeans like thismobileno,customername,ticket_detail,createdDate etc.....Regards,ASIF |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2010-04-06 : 17:08:20
|
| id ticket_no customer_id location distributor date_of_buy ticket_status mobile CustomerName1 1 1 East Asef 04/04/2010 Open 966502146894 asifbhura |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-04-06 : 17:16:26
|
| Looks like a PEBKAC issue to me.There are 10 types of people in the world, those that understand binary, and those that don't. |
 |
|
|
|