Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    18
    Member #
    18818
    Hello All!

    I know there is probably a simple solution to this. I just can't see it at the moment.

    I want to join the data from two tables. The thing is one table stores a name in one field containing the full name and the other stores a name in two fields: first name in one field and last name in the other.

    The correct data gets pulled from table2 but it is matched with each name in table1. Hence the 'duplicate/double' results as table1 only has 2 names in it at the moment for testing.

    Example Results:
    Code:
    ------------------------------------------------------------------
    table1.first_name | table1.last_name | table1.data1 | table2.name
    ------------------------------------------------------------------
           John               Smith           XX          Jane Doe
    ------------------------------------------------------------------
           Jane                Doe            XX          Jane Doe
    ------------------------------------------------------------------
    I just want to match all the Jane Doe data in table2 with that of the Jane Doe data in table1. Not have Jane Doe in table2 matched to each name in table1.

    Here's my code.
    Code:
    SELECT * FROM table1
    JOIN table2
    WHERE table2.name IN (SELECT CONCAT(first_name, ' ', last_name) FROM table1)
    Any help you can give me will be greatly appreciated!

    Thanks,
    Jared

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:19 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com