Google Groups Home
Help | Sign in
Message from discussion Run query in background while showing "Please wait"
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
b logica  
View profile
 More options Mar 27, 3:33 pm
From: "b logica" <foo.log...@gmail.com>
Date: Thu, 27 Mar 2008 15:33:58 -0400
Local: Thurs, Mar 27 2008 3:33 pm
Subject: Re: Run query in background while showing "Please wait"

On Thu, Mar 27, 2008 at 12:59 PM, kdecapite <decap...@creationsite.com> wrote:

>  I may have not explained the setup properly. I don't actually have a
>  "full_name" field in either table (import_contacts and contacts are
>  the actual MySQL table names). Each of these tables have "fn" and "ln"
>  fields, however. So the problem is that I need to somehow find all
>  records in the contacts table which have the same values in the "fn"
>  and "ln" fields as the import_contacts table.

I could be misinterpreting your needs, but ...

SELECT c.id, c.fn, c.ln FROM contacts AS c
INNER JOIN import_contacts AS ic ON c.fn = ic.fn AND c.ln = ic.ln;

This will select the id, fn, and ln from contacts where it also exists
in import_contacts.

>  The only idea I have at the moment is to create a field in both tables
>  which simply stores the concatenated value of a record's "fn" and "ln"
>  fields. This would require me to write a script to retro-fit the
>  existing 30k contact records, as well as update some logic in my "add
>  contact" controller. Not to mention this would also create a redundant
>  field in the table and still doesn't ultimately solve the problem
>  because what if in the future I want to find duplicates matching "fn",
>  "ln" and "mi" (middle initial)? I would have to create yet another
>  "dummy" field in my table.

UPDATE TABLE contacts ADD COLUMN full_name VARCHAR(128);  -- or whatever size
UPDATE TABLE contacts SET full_name = CONCAT_WS(' ', fn, ln);

BUT, you'd probably be far better off simply creating an index on the tables:

CREATE INDEX contacts_fullname ON contacts (fn, ln);
CREATE INDEX import_contacts_fullname ON import_contacts (fn, ln);

This is all for MySQL, which i'm assuming you're using.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google