| Author |
Topic |
|
kgadde
Starting Member
5 Posts |
Posted - 2008-06-14 : 13:18:24
|
| hithis seems to be a simple query. but i could not get it for the last 2 days. so please help.i have 2 tables.1.lineup table 2.station tableScript for 2 tablesCREATE TABLE [dbo].[lineup]( [LineUpID] [int] IDENTITY(1,1) NOT NULL, [headend_id] [int] NULL, [station_num] [int] NULL, [Channel_position] [int] NULL, [CreateDate] [smalldatetime] NULL) ON [PRIMARY]CREATE TABLE [dbo].[station]( [StationId] [int] IDENTITY(1,1) NOT NULL, [Station_num] [int] NOT NULL, [Station_call_sign] [varchar](10) NULL, [CreateDate] [smalldatetime] NULL) ON [PRIMARY]insert into lineup ("lineupid","headend_id","station_num","channel_position","createdate") values ('4182570','90973','19510','10','04/09/2008')insert into lineup ("lineupid","headend_id","station_num","channel_position","createdate") values ('4182575','90973','10000','120','04/09/2008')insert into lineup ("lineupid","headend_id","station_num","channel_position","createdate") values ('4182000','90000','12200','100','04/09/2008')insert into lineup ("lineupid","headend_id","station_num","channel_position","createdate") values ('4182333','90234','12270','15','04/09/2008')insert into lineup ("lineupid","headend_id","station_num","channel_position","createdate") values ('4182570','90973','19510','10','04/10/2008')insert into lineup ("lineupid","headend_id","station_num","channel_position","createdate") values ('4182575','90973','10000','120','04/10/2008')insert into lineup ("lineupid","headend_id","station_num","channel_position","createdate") values ('4182000','90000','12200','100','04/10/2008')insert into lineup ("lineupid","headend_id","station_num","channel_position","createdate") values ('4182333','90234','12270','15','04/10/2008')insert into station ("stationid","station_num","station_call_sign","createdate") values ('300','10000','ESPN','04/10/2008'i want the result to be in this formatfor the following columns.i need all rows for headend_id = 90973 and createdate = 04/10/2008please help thanks in advancethe resultset column names should have :headend_id channel_position station_call_sign station_num |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-14 : 14:07:46
|
| [code]SELECT l.headend_id,l.channel_position,s.station_call_sign, l.station_numFROM lineup lLEFT JOIN station sON s.station_num=i.station_numWHERE l.headend_id = 90973 and l.createdate = 04/10/2008[/code]If you want only those records in lineup having matching records in station change LEFT JOIN to INNER JOIN |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-14 : 14:09:26
|
| And you need to use single quotes around the date valuesMadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-14 : 14:11:38
|
quote: Originally posted by madhivanan And you need to use single quotes around the date valuesMadhivananFailing to plan is Planning to fail
Hi Madhi. Still in hunt. So when are you returning to India? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-14 : 14:33:56
|
quote: Originally posted by visakh16
quote: Originally posted by madhivanan And you need to use single quotes around the date valuesMadhivananFailing to plan is Planning to fail
Hi Madhi. Still in hunt. So when are you returning to India?
Next month MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-14 : 14:42:21
|
quote: Originally posted by madhivanan
quote: Originally posted by visakh16
quote: Originally posted by madhivanan And you need to use single quotes around the date valuesMadhivananFailing to plan is Planning to fail
Hi Madhi. Still in hunt. So when are you returning to India?
Next month MadhivananFailing to plan is Planning to fail
Cool |
 |
|
|
kgadde
Starting Member
5 Posts |
Posted - 2008-06-14 : 22:05:51
|
| thanks for the reply guys.i got what i expectedthanks |
 |
|
|
|
|
|