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
 Development Tools
 Other Development Tools
 SQL Inner Join

Author  Topic 

jollygupta9
Starting Member

1 Post

Posted - 2009-03-14 : 01:49:26
I have 2 tables:-

Table 1 Table 2
Date Hour Hour Id
2008-08-01 Hr Hr 1
2008-08-02 Hr Hr 2
2008-08-03 Hr Hr 3

Now, if I do inner join on Hour field my o/p shld be

2008-08-01 1 Hr
2008-08-01 2 Hr
2008-08-01 3 Hr

2008-08-02 1 Hr
2008-08-02 2 Hr
2008-08-02 3 Hr

2008-08-03 1 Hr
2008-08-03 2 Hr
2008-08-03 3 Hr

but i am getting o/p like
2008-08-01 1 Hr
2008-08-01 2 Hr
2008-08-01 3 Hr

2008-08-02 1 Hr

2008-08-03 1 Hr
Can anybody please let me know the reason. Thanks

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-03-16 : 06:09:13
quote:

Table 1 Table 2
Date Hour Hour Id
2008-08-01 Hr Hr 1
2008-08-02 Hr Hr 2
2008-08-03 Hr Hr 3


HUH?

Please post the table definition for your tables (including data types) -- I can't tell which columns are in which tables.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-03-16 : 06:21:02
Also, If you can format your post. That'll be great.
Go to Top of Page

under2811
Constraint Violating Yak Guru

366 Posts

Posted - 2009-06-04 : 09:30:22
select a.Date, b.Id, a.Hour
from Table_1 a ,Table_2 b
order by 1
Go to Top of Page
   

- Advertisement -