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 |
|
duhaas
Constraint Violating Yak Guru
310 Posts |
Posted - 2006-09-12 : 17:03:48
|
| I have a situation where I want to join two colums, both called accountnumber, but I want to join them on the charecters 3-8 of one of the two accountnumbers. Example:Table 1acctnumber = 1601804800Ftable 2acctnumber = 018048 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-09-12 : 17:12:18
|
| JOIN ...ON SUBSTRING(a1.accountnumber, 3, 6) = SUBSTRING(a2.accountnumber, 3, 6)Tara Kizer |
 |
|
|
duhaas
Constraint Violating Yak Guru
310 Posts |
Posted - 2006-09-12 : 17:25:30
|
| Thanks for your help, I must have syntax wrong somewhere:select g.ACCTNO, r.Acctnumberfrom Accounts as g, goldreview as rjoin accounts on substring(g.ACCTNO,3,6) = substring(r.Acctnumber,3,6)The column prefix 'g' does not match with a table name or alias name used in the query. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-09-12 : 17:26:59
|
| You are combining the old join syntax with the new join syntax. Here's how it should look using the new join syntax:select g.ACCTNO, r.Acctnumberfrom Accounts g inner join goldreview ron substring(g.ACCTNO,3,6) = substring(r.Acctnumber,3,6)Tara Kizer |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-09-13 : 10:00:43
|
| I think the questioner wants to take substring from only one table's columnselect g.ACCTNO, r.Acctnumberfrom Accounts T1 inner join goldreview T2on substring(T1.ACCTNO,3,6) = t2.AcctnumberMadhivananFailing to plan is Planning to fail |
 |
|
|
duhaas
Constraint Violating Yak Guru
310 Posts |
Posted - 2006-09-13 : 10:23:40
|
| Appreciate the followup, i made the adjustment myself, but love the assistance, I might not of phrased the question well |
 |
|
|
|
|
|
|
|