Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7568785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:00:39+00:00 2026-05-30T15:00:39+00:00

I have a database with three tables and I need to cross reference the

  • 0

I have a database with three tables and I need to cross reference the first table against the other two to create a fourth table of consolidated information. All the tables have one field which is common, this is the MSISDN (mobile / cell telephone number) and is at least 10 digits long.

Table 1 – 819,248 rows

Table 2 – 75,308,813 rows

Table 3 – 17,701,196 rows

I want to return all the rows from Table 1 and append some of the fields from Tables 2 and Table 3 when there’s a matching MSISDN.
My query has been running now for over 24 hours and I have no way of knowing how long something like this should take.

This type of query may be a regular project – is there a way to significantly reduce the query time?

I have indexed tables 2 and 3 with MSISDN and the fields I need to return.

My query is like this:

create TABLE FinishedData 
select 
   Table1.ADDRESS, table1.POSTAL, table1.MOBILE, 
   table1.FIRST, table1.LAST, table1.MID, table1.CARRIER, 
   table1.TOWN, table1.ID, table2.status as 'status1', 
   table2.CurrentNetworkName as 'currentnetwork1', 
   table2.DateChecked as 'datechecked1', table3.Status as 'status2', 
   table3.CurrentNetworkName 'currentnetwork2', 
   table3.DateChecked as 'datechecked2' 
from 
   table1 left join (table2, table3) 
       on (right(table1.MOBILE, 10) = right(table2.MSISDN, 10) 
       AND right(table1.MOBILE,10) = right(table3.MSISDN,10))

MySQL is running on a 64bit windows machine with 12GB memory and 8 logical cores @ 3GHz. MySQLd is only using 10% cpu and 600MB of resources when running the query.

Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:00:40+00:00Added an answer on May 30, 2026 at 3:00 pm

    The kill performance issue is with right function When you use this function, MySQL can’t use indexes.

    My suggest is:

    1. Create new fields in table2 and table 3 with reverse content of MSISDN
    2. Make the join replacing right function by left function.

    With this little change MySQL will can take indexes to make your joins.

    Explained steps:

    1) Create new columns:

    Alter table table2 add column r_MSISDN varchar(200);
    update table2 set r_MSISDN = reverse( MSISDN );
    
    Alter table table3 add column r_MSISDN varchar(200);
    update table3 set r_MSISDN = reverse( MSISDN );
    

    2) New join:

    ...
    from 
       table1 left join (table2, table3) 
           on (right(table1.MOBILE, 10) = left(table2.r_MSISDN, 10) 
           AND right(table1.MOBILE,10) = left(table3.r_MSISDN,10))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables in my database. First table is Employee : Second table
I have a MySql database with three tables I need to combine in a
I have a common database joining situation involving three tables. One table, A, is
I have three tables in an SQL 2005 database, that I need to query
I have a database with three tables, a household table, an adults table and
I have to create a database with three tables one for country then State
Ok, I have three tables. The parent table is Listings and two child tables
I have a database with three tables: user_table country_table city_table I want to write
I have three database tables: users emails invitations Emails are linked to users by
We have two tables in a SQL Server 2005 database, A and B.There is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.