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
 General SQL Server Forums
 New to SQL Server Programming
 lookup two tables

Author  Topic 

Topaz
Posting Yak Master

199 Posts

Posted - 2008-10-22 : 04:35:06
I have two tables in my SQL db. One called wce_contact and the other called wce_history.

Would i be able to create a lookup looking like this:

select website from wce_contact where notes not null in wce_history

hope that makes sense. Im trying to find the websites in the db that dont have notes, but the website field is in one table and the notes field is in the other

JT

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-22 : 04:40:45
[code]select website from wce_contact c
left join wce_history h
on h.linkingcol=c.linkingcol
where h.notes is null[/code]
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2008-10-22 : 06:27:03
Msg 207, Level 16, State 1, Line 3
Invalid column name 'linkingcol'.
Msg 207, Level 16, State 1, Line 3
Invalid column name 'linkingcol'.


whats up?

JT
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-22 : 06:29:44
quote:
Originally posted by Topaz

Msg 207, Level 16, State 1, Line 3
Invalid column name 'linkingcol'.
Msg 207, Level 16, State 1, Line 3
Invalid column name 'linkingcol'.


whats up?

JT


i gave generalised name becuse i dont know what columns by which tables are linked. replace it by your actual column names in your tables.
Go to Top of Page

Leo_Don
Starting Member

42 Posts

Posted - 2008-10-22 : 06:34:21
quote:
Originally posted by Topaz

I have two tables in my SQL db. One called wce_contact and the other called wce_history.

Would i be able to create a lookup looking like this:

select website from wce_contact where notes not null in wce_history

hope that makes sense. Im trying to find the websites in the db that dont have notes, but the website field is in one table and the notes field is in the other

JT



select website
from wce_contact, wce_history
where wce_history.notes <> null
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2008-10-22 : 06:39:18
quote:
Originally posted by Leo_Don

quote:
Originally posted by Topaz

I have two tables in my SQL db. One called wce_contact and the other called wce_history.

Would i be able to create a lookup looking like this:

select website from wce_contact where notes not null in wce_history

hope that makes sense. Im trying to find the websites in the db that dont have notes, but the website field is in one table and the notes field is in the other

JT



select website
from wce_contact, wce_history
where wce_history.notes <> null



I get this from the latest query

Msg 306, Level 16, State 1, Line 1
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.


JT
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-22 : 06:45:05
quote:
Originally posted by Topaz

quote:
Originally posted by Leo_Don

quote:
Originally posted by Topaz

I have two tables in my SQL db. One called wce_contact and the other called wce_history.

Would i be able to create a lookup looking like this:

select website from wce_contact where notes not null in wce_history

hope that makes sense. Im trying to find the websites in the db that dont have notes, but the website field is in one table and the notes field is in the other

JT



select website
from wce_contact, wce_history
where wce_history.notes <> null



I get this from the latest query

Msg 306, Level 16, State 1, Line 1
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.


JT


then try casting it to varchar(max)
Go to Top of Page
   

- Advertisement -