Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 11th, 2005, 10:05 PM
zobernjik zobernjik is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Australia
Posts: 139 zobernjik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 31 m 10 sec
Reputation Power: 5
Unhappy help linking tables

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?

Reply With Quote
  #2  
Old January 11th, 2005, 11:51 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,764 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 6 h 8 m 20 sec
Reputation Power: 452
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.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > help linking tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT