Solved

Cannot join memo field

Posted on 2013-12-16
8
482 Views
Last Modified: 2013-12-19
Hi,

I have SQL code and im trying to join memo fields


Is someone able to add the line of SQL

Where Left([INPUT D2 DATA].[Customer Type], 255) = Left([Calculation D2].[Client Type], 255

Im new to SQL so keep getting the syntax wrong.

Many thanks

SELECT INPUT_D2_all.ID, INPUT_D2_all.ClientID, INPUT_D2_all.[Customer Type Family], INPUT_D2_all.[Customer Type], INPUT_D2_all.LoB, INPUT_D2_all.Segment, INPUT_D2_all.[Business Type], INPUT_D2_all.[Employment Status], INPUT_D2_all.[Key controller flag], INPUT_D2_all.[Country of Incorp/ Registration / Trust Est], INPUT_D2_all.[Country of Primary Operation], INPUT_D2_all.[Country of Business Focus], INPUT_D2_all.[Country of SoW], INPUT_D2_all.[Country of Nationality / Citizenship], INPUT_D2_all.[Country of Perm Residence], INPUT_D2_all.[Country of Government], INPUT_D2_all.[Legal Entity Structure], INPUT_D2_all.[Product Risk], INPUT_D2_all.[Trade Flag], INPUT_D2_all.[PCM Flag], INPUT_D2_all.[Safe Deposit Product Flag], INPUT_D2_all.[$ Cash transactions - m1], INPUT_D2_all.[$ Cash transactions - m2], INPUT_D2_all.[$ Cash transactions - m3], INPUT_D2_all.[$ Cash transactions - m4], INPUT_D2_all.[$ Cash transactions - m5], INPUT_D2_all.[$ Cash transactions - m6], INPUT_D2_all.[$ Cash transactions - m7], INPUT_D2_all.[$ Cash transactions - m8], INPUT_D2_all.[$ Cash transactions - m9], INPUT_D2_all.[$ Cash transactions - m10], INPUT_D2_all.[$ Cash transactions - m11], INPUT_D2_all.[$ Cash transactions - m12], INPUT_D2_all.[# Cash transactions - m1], INPUT_D2_all.[# Cash transactions - m2], INPUT_D2_all.[# Cash transactions - m3], INPUT_D2_all.[# Cash transactions - m4], INPUT_D2_all.[# Cash transactions - m5], INPUT_D2_all.[# Cash transactions - m6], INPUT_D2_all.[# Cash transactions - m7], INPUT_D2_all.[# Cash transactions - m8], INPUT_D2_all.[# Cash transactions - m9], INPUT_D2_all.[# Cash transactions - m10], INPUT_D2_all.[# Cash transactions - m11], INPUT_D2_all.[# Cash transactions - m12], INPUT_D2_all.[$ Cross-border wires m1], INPUT_D2_all.[$ Cross-border wires m2], INPUT_D2_all.[$ Cross-border wires m3], INPUT_D2_all.[$ Cross-border wires m4], INPUT_D2_all.[$ Cross-border wires m5], INPUT_D2_all.[$ Cross-border wires m6], INPUT_D2_all.[$ Cross-border wires m7], INPUT_D2_all.[$ Cross-border wires m8], INPUT_D2_all.[$ Cross-border wires m9], INPUT_D2_all.[$ Cross-border wires m10], INPUT_D2_all.[$ Cross-border wires m11], INPUT_D2_all.[$ Cross-border wires m12], INPUT_D2_all.[# Cross-border wires - m1], INPUT_D2_all.[# Cross-border wires - m2], INPUT_D2_all.[# Cross-border wires - m3], INPUT_D2_all.[# Cross-border wires - m4], INPUT_D2_all.[# Cross-border wires - m5], INPUT_D2_all.[# Cross-border wires - m6], INPUT_D2_all.[# Cross-border wires - m7], INPUT_D2_all.[# Cross-border wires - m8], INPUT_D2_all.[# Cross-border wires - m9], INPUT_D2_all.[# Cross-border wires - m10], INPUT_D2_all.[# Cross-border wires - m11], INPUT_D2_all.[# Cross-border wires - m12], INPUT_D2_all.[$ PCM wires - m1], INPUT_D2_all.[$ PCM wires - m2], INPUT_D2_all.[$ PCM wires - m3], INPUT_D2_all.[$ PCM wires - m4], INPUT_D2_all.[$ PCM wires - m5], INPUT_D2_all.[$ PCM wires - m6], INPUT_D2_all.[$ PCM wires - m7], INPUT_D2_all.[$ PCM wires - m8], INPUT_D2_all.[$ PCM wires - m9], INPUT_D2_all.[$ PCM wires - m10], INPUT_D2_all.[$ PCM wires - m11], INPUT_D2_all.[$ PCM wires - m12], INPUT_D2_all.[# PCM wires - m1], INPUT_D2_all.[# PCM wires - m2], INPUT_D2_all.[# PCM wires - m3], INPUT_D2_all.[# PCM wires - m4], INPUT_D2_all.[# PCM wires - m5], INPUT_D2_all.[# PCM wires - m6], INPUT_D2_all.[# PCM wires - m7], INPUT_D2_all.[# PCM wires - m8], INPUT_D2_all.[# PCM wires - m9], INPUT_D2_all.[# PCM wires - m10], INPUT_D2_all.[# PCM wires - m11], INPUT_D2_all.[# PCM wires - m12], INPUT_D2_all.[$ wires to high risk countries m1], INPUT_D2_all.[$ wires to high risk countries m2], INPUT_D2_all.[$ wires to high risk countries m3], INPUT_D2_all.[$ wires to high risk countries m4], INPUT_D2_all.[$ wires to high risk countries m5], INPUT_D2_all.[$ wires to high risk countries m6], INPUT_D2_all.[$ wires to high risk countries m7], INPUT_D2_all.[$ wires to high risk countries m8], INPUT_D2_all.[$ wires to high risk countries m9], INPUT_D2_all.[$ wires to high risk countries m10], INPUT_D2_all.[$ wires to high risk countries m11], INPUT_D2_all.[$ wires to high risk countries m12], INPUT_D2_all.[# wires to high risk countries m1], INPUT_D2_all.[# wires to high risk countries m2], INPUT_D2_all.[# wires to high risk countries m3], INPUT_D2_all.[# wires to high risk countries m4], INPUT_D2_all.[# wires to high risk countries m5], INPUT_D2_all.[# wires to high risk countries m6], INPUT_D2_all.[# wires to high risk countries m7], INPUT_D2_all.[# wires to high risk countries m8], INPUT_D2_all.[# wires to high risk countries m9], INPUT_D2_all.[# wires to high risk countries m10], INPUT_D2_all.[# wires to high risk countries m11], INPUT_D2_all.[# wires to high risk countries m12], INPUT_D2_all.[Turnover (GPB HNAH only)], INPUT_D2_all.[SCC flag], INPUT_D2_all.[SCC reason], INPUT_D2_all.[Previous Risk Rating], INPUT_D2_all.[Previous Country Risk Factor Rating], INPUT_D2_all.[Previous Business Type Risk Factor Rating], INPUT_D2_all.[Previous Legal Entity Risk Factor rating], INPUT_D2_all.[Previous Product Risk Factor Rating], INPUT_D2_all.[Assumption flag], INPUT_D2_all.LOB1, INPUT_D2_all.Country, INPUT_D2_all.[Cash Only], INPUT_D2_all.[Cash/Xborder], INPUT_D2_all.PRR, Calculation_D2_all.[Overal RAG]
FROM Calculation_D2_all INNER JOIN INPUT_D2_all ON Calculation_D2_all.[Client Type] = INPUT_D2_all.ClientID
WHERE (((INPUT_D2_all.LOB1)="GPB"));
0
Comment
Question by:Seamus2626
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 167 total points
ID: 39721087
The simplest, I guess, would be to combine the join into the where clause:

FROM
    INPUT_D2_all,
    Calculation_D2_all
Where
    [INPUT_D2_all].[ClientID] = [Calculation_D2_all].[Client Type]
    And
    Left([INPUT D2 DATA].[Customer Type], 255) = Left([Calculation D2].[Client Type], 255)

/gustav
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 167 total points
ID: 39721089
Why is Customer_Type a Memo field?  Just seems unusual (I asked this in one of your other questions as well).  From the field name, it seems like a text field would be a better choice... versus something like 'Notes' which may receive a lot of user input.

If you could change the field to TEXT (even with a long length such as 500), you would eliminate this "can't join on memo" issue.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39721097
Plus, that Left(FieldName,255) in the JOIN seems like a hack.  

If the field can contain more than 255 characters, you would run into problems with the JOIN if any differences occurred after the first 255 characters,  

If the field contains 255 characters or LESS, why not cleanly eliminate the problem by defining it as Text instead of Memo?
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:Seamus2626
ID: 39721100
When i try and change data type, i get the error "Microsoft Access cant change the data type"

There isnt enough disk space or memory
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39721115
Have you tried compact/repairing the database?
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 39721118
It is a hack but it works as you can't join memo fields. No repair is needed.

It doesn't matter if a memo holds more than 255 chars but, of course, the first the first 255 chars should be unique if any memo field is considered unique.

/gustav
0
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 166 total points
ID: 39721138
Just to kick in a comment or two, I can't think of any logical reason why you'd want to join on a memo field, which means more then likely, your database design needs some re-work.

A word to the wise: I'd stop and do that now before you continue on as this will just be the start of many issues.

Access (and other relational products) were desinged to work with properly structured databases.   If your database is not, then it's not going to work well, and maybe not even at all.

For example, while you might be able to hack a join on the first 255 characters, the CPU/memory requirements will be intensive.   Performance will be dismal and you may find it no longer works even with ten or twenty thousand records.

Jim.
0
 

Author Closing Comment

by:Seamus2626
ID: 39728687
Rebuild is needed!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question