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)
 SQL Statement help

Author  Topic 

caddyjoe77
Starting Member

3 Posts

Posted - 2007-08-18 : 09:19:18
Hi, i am building a DB driven asp app. I need some help with a sql statement if you would be so kind.

i have two tables with 1 common field called ittnumber. What i am trying to do is generate all the associated ittnumber log entried and display in a gridview under the ittnumber selected.

here is the sql statement i came up with, the syntax is correct according to SQL but i get 0 results.

select dbo.tbllog.ittnumber, dbo.tbllog.ittlog, dbo.tbllog.logdate, dbo.tbl3215.ittnumber
from dbo.tbllog, dbo.tbl3215 where dbo.tbllog.ittnumber = dbo.tbl3215.ittnumber


thanks for the help!

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-18 : 10:29:34
learn to write joins.
the syntax you're using is deprecated.

the way you have it written is an inner join.
this means that you don't have matching ittnumber's in both tables.


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-18 : 10:46:27
select dbo.tbllog.ittnumber, dbo.tbllog.ittlog, dbo.tbllog.logdate, dbo.tbl3215.ittnumber
from dbo.tbllog AS l
left join dbo.tbl3215 as n on n.ittnumber = l.ittnumber



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -