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 2000 Forums
 SQL Server Development (2000)
 join help

Author  Topic 

QuietRiot
Yak Posting Veteran

67 Posts

Posted - 2008-01-17 : 15:09:31

I have one table called AccountInfo that contains many values i just want accountnumber and AccountName

I have another table called AccountCustomFieldValues.

both of these have AccountNumber.

Select AccountNumber, AccountName
from accountinfo a, accountcustomfieldvalues b,
where a.accountnumber = b.accountnumber
and a.networkcontrolindicator = '0'
and b.fieldID='9' and b.fieldvalue = 'nscc'

whats wrong with this query?

jdaman
Constraint Violating Yak Guru

354 Posts

Posted - 2008-01-17 : 15:12:39
You need to add table alias to the column names in your select statement.
Go to Top of Page

QuietRiot
Yak Posting Veteran

67 Posts

Posted - 2008-01-17 : 15:21:14
hmm

still getting an error on the 3rd line with where?
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'where'.
Go to Top of Page

jdaman
Constraint Violating Yak Guru

354 Posts

Posted - 2008-01-17 : 15:23:55
There is also an extra comma in your from clause:

from accountinfo a, accountcustomfieldvalues b,
Go to Top of Page

QuietRiot
Yak Posting Veteran

67 Posts

Posted - 2008-01-17 : 15:32:57
quote:
Originally posted by jdaman

There is also an extra comma in your from clause:

from accountinfo a, accountcustomfieldvalues b,



damn
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-01-17 : 15:34:07
Or use ANSI-style of JOIN.

Select a.AccountNumber, AccountName
from accountinfo a JOIN accountcustomfieldvalues b
ON a.accountnumber = b.accountnumber
Where a.networkcontrolindicator = '0'
and b.fieldID='9' and b.fieldvalue = 'nscc'


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -