Solved

Cannot join memo field

Posted on 2013-12-16
8
478 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
 

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

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.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

895 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now