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 543k
  • Answers 543k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There is no guarantee that it will all arrive at… May 17, 2026 at 6:26 am
  • Editorial Team
    Editorial Team added an answer The SQLite documentation page has a great section named SQLite… May 17, 2026 at 6:26 am
  • Editorial Team
    Editorial Team added an answer Consider using iframes to show the child pages. That way,… May 17, 2026 at 6:26 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 need to create an SQL query to insert some data into a table
Data table structure is: id1,id2,id3,id4,... (some other fields). I want to create summary query
The Table - Query has 2 columns (functionId, depFunctionId) I want all values that
If I query a table with a condition on the key field as in:
I need to query a table for values given a string. The table is
Nearly identical to Query a Table's Foreign Key relationships , but for SQL Server
I have two tables: CREATE TABLE 'sales_sheet' ( `_id` int(11) NOT NULL AUTO_INCREMENT, `_typed_by`
I have a multi-table query, similar to this (simplified version) SELECT columns, count(table2.rev_id) As
I need to query the table for all but keyword. Using just - doesn't
I'm building a quick csv from a mysql table with a query like: select

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.