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 1098537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:35:36+00:00 2026-05-17T00:35:36+00:00

Table 1 : QUERY: Create table client ( applicationNo int primary key, name varchar(20)

  • 0

Table 1 :
QUERY: Create table client (
applicationNo int primary key,
name varchar(20)
);

Insert statement: Insert into client values (1,’XYZ’),(1,’ABC’),(1,’DEF’);

applicationNo   |   name  
    1           |   XYZ  
    2           |   ABC  
    3           |   DEF  

Table 2:
Query : Create table client (
applicationNo int,
phoneNo Bigint,
foreign key (applicationNo) references client (applicationNo),
primary key(applicationNO,phoneNo)
);

Insert into phoneNO values (1,999999),(1,888888),(2,777777),(3,666666),(3,555555);

applicationNo | phoneNo
1             |   999999
1             |   888888
2             |   777777
3             |   666666
3             |   555555

Can I retrieve the tuples by joining both the tables in such a way that get the following output, but using single query, also I’m using mysql 5.1

applicationNo |   name | phoneNo1 | phoneNo2 
1             |   XYZ  |  999999  |   88888
2             |   ABC  |  77777   |   Null
3             |   DEF  |  66666   |   555555

Edited : extra information
I tried using this something called cross tab .But I’m not able to use the totalPhoneNo inside the case statement

SELECT applicationNo,count(phoneNo) as totalPhoneNo,  
SUM(CASE WHEN totalPhoneNo= 1 THEN phoneNO ELSE Null END) AS phoneNo1,  
SUM(CASE WHEN totalPhoneNO = 2 THEN phoneNo ELSE Null END) AS phoneNo2  
FROM phoneNO GROUP BY applicationNo;
  • 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-17T00:35:36+00:00Added an answer on May 17, 2026 at 12:35 am

    Try:

    select c.applicationNo, 
           max(c.name) name,
           max(p.phoneNo) phoneNo1,
           case 
               when max(p.phoneNo) = min(p.phoneNo) then NULL 
               else min(p.phoneNo) 
           end phoneNo2
    from client c
    left join phoneNo p on c.applicationNo = p.applicationNo
    group by c.applicationNo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 541k
  • Answers 541k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I just tried it with HQL and it does not… May 17, 2026 at 2:56 am
  • Editorial Team
    Editorial Team added an answer MailMessage message = new MailMessage(from, to, subject, body); message.IsBodyHtml =… May 17, 2026 at 2:56 am
  • Editorial Team
    Editorial Team added an answer It looks like the tutorials are missing some of the… May 17, 2026 at 2:56 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have two tables: CREATE TABLE 'sales_sheet' ( `_id` int(11) NOT NULL AUTO_INCREMENT, `_typed_by`
I'm trying to create to use a table as a look-up table. Normally, I
I've a mobile application. My client has a large data set ~100.000 records. It's
In several web application projects I've been a part of, the client asks to
I'm using .NET RIA Services July Preview to communicate between my Silverlight client and
I'm working on integrating some data from a 3rd-Party system into one of my
I have a legacy VB6 application that was built using MSDE. As many client's
I have an unnormalized events-diary CSV from a client that I'm trying to load
perhaps I'm missing something, but I need a client side database pre-populated with a
I have a SQL query and it fails at times. That means that query

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.