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.
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 AccountNameI have another table called AccountCustomFieldValues.both of these have AccountNumber.Select AccountNumber, AccountNamefrom accountinfo a, accountcustomfieldvalues b, where a.accountnumber = b.accountnumberand 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. |
 |
|
QuietRiot
Yak Posting Veteran
67 Posts |
Posted - 2008-01-17 : 15:21:14
|
hmmstill getting an error on the 3rd line with where?Server: Msg 156, Level 15, State 1, Line 3Incorrect syntax near the keyword 'where'. |
 |
|
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, |
 |
|
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 |
 |
|
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, AccountNamefrom accountinfo a JOIN accountcustomfieldvalues b ON a.accountnumber = b.accountnumberWhere a.networkcontrolindicator = '0'and b.fieldID='9' and b.fieldvalue = 'nscc' Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|