|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am really stuck. This is the query I need help on
"select a.RecordID as RecordDTA , a.RelocateID as RelocateDTA , a.WhenConfirmed as WhenConfirmedDTA , b.RequestID , b.DocumentID , b.RequestWhen from RelocateeDTA a left join docRequests b on convert(varchar(30),a.RecordID) = b.WhereClause" What I am trying to do is to link two tables but they are of a different field type and that is why I have converstion but what seems to be my problem is that when I run the query I only get results for the RelocateeDTA table or docRequests table, depending how I twist around the query, but all the field from the other table that I am linking the first table on are always empty/NULLS The reason for that is because RecordID from RelocateeDTA is an integer so saves ID (2667 for example) but field I am linking it to is a varchar and values saved in that field look like "{RelocateeDTA.RecordID}=2667 and they when I am doing a query it can't find any matching records. So how can I write this query so when I link these tables focuses only on the ID number from this piece of text "{RelocateeDTA.RecordID}=2667 " which should be comparable to RecordID from RelocateeDTA table. I hope I am making sense and I really need help. Anybody? |
|
#2
|
||||
|
||||
|
You could try something like this.
Code:
SELECT A.RecordID As RecordDTA,
A.RelocateID As RelocateDTA,
A.WhenConfirmed As WhenConfirmedDTA,
B.RequestID,
B.DocumentID,
B.RequestWhen
FROM RelocateeDTA As A
LEFT JOIN DocRequests As B On (A.RecordID = Cast(Substring(B.RecordIDField, CharIndex("=", B.RecordIDField), Len(B.RecordIDField) - CharIndex("=", B.RecordIDField)) As int)
You'll need to play around with it to get it right. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > help linking tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|