0

Using MS Access, I have to combine two tables where two criteria must be met: Container = Container AND Booking = Booking.

I have two tables where fields are missing a value:

Table1 and Table2 have in common two colunmns:

Container Booking

Table 2 has additional column "Date". I need to add "Date" to Table1.

Problem is

Container is often missing a "check digit" at the end, so it may be 10 or 11 characters, so i need to match first 10 of container

Booking is often missing a leading zero, so it may be 9 or 10 numbers, so i need to match last 9 of booking.

The following does not work when one or the other Table are missing a leading zero and/or container check digit. How do i adjust SQL?

RIGHT JOIN Table1 ON Table2.[Booking] = Table1.[Booking] AND Table2.[Container] = Table1.[Container];
  • Containers can be reused on new bookings so booking number must also be match.
asked Feb 11, 2014 at 18:47
2
  • When you say is missing a leading 0,need to match last 9 does it mean you have 10 digits or just 9? Commented Feb 11, 2014 at 19:30
  • No leading zero means booking has 9 numbers Commented Feb 11, 2014 at 19:40

1 Answer 1

0

Not ultra familiar with Access, but I'm pretty sure you have LEFT and RIGHT functions available to you. Something like this seems likely to work:

 ON RIGHT( Table2.[Booking], 9 ) = RIGHT( Table1.[Booking], 9 )
 AND LEFT( Table2.[Container], 10 ) = LEFT( Table1.[Container], 10 );
answered Feb 11, 2014 at 20:38
1
  • Wow, too easy. A lot like excel. Commented Feb 11, 2014 at 22:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.