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

  • Home
  • SEARCH
  • 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 3490266
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:29:43+00:00 2026-05-18T11:29:43+00:00

Ok, so I have two tables in MySQL. One table holds customer information, the

  • 0

Ok, so I have two tables in MySQL. One table holds customer information, the other holds phone numbers. I need to join these tables in one query to select up to two phone numbers from the phones table as well as customer information. right now my query is:

SELECT customers.name, phones.phone, phones2.phone 
FROM customers 
LEFT JOIN phones ON phones.customerid=customers.id 
LEFT JOIN phones AS phones2 ON phones2.customerid=customers.id 
GROUP BY customers.id;

However, this returns the same phone number for phone 1 and phone 2. essentially what I need to do is offset phones2 by 1, but I don’t know how to do that syntactically.

The phones are in a separate table because it’s a one to many relationship.

I need this to be in one query because I’m exporting this directly to a csv.

Help is much appreciated. Thanks in advance.

  • 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-18T11:29:43+00:00Added an answer on May 18, 2026 at 11:29 am

    To avoid getting the same phone number twice you could change this:

    LEFT JOIN phones AS phones2 ON phones2.customerid=customers.id 
    

    To this:

    LEFT JOIN phones AS phones2 ON phones2.customerid=customers.id
    AND phones2.phone <> phones.phone
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, one holds the information of contributors to my site and
I have two mysql tables, one containing details on cars and one containing all
I have two tables here - one is in UTF and holds Arabic text
I have two tables, one for bookings and one for room allocations. Booking table
I have two MySQL tables: One for items and another to log purchases. I'm
I have two tables. One table is meant to serve as a transaction history
I have two MySQL tables named 'nodes' and 'joinTable' like shown below. I need
I have two tables, both with start time and end time fields. I need
I have two tables, one that contains volunteers, and one that contains venues. Volunteers
I have a table with two child tables. For each record in the parent

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.