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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:00:34+00:00 2026-06-03T09:00:34+00:00

I’ve managed to create a view from some data in my MySQL database, as

  • 0

I’ve managed to create a view from some data in my MySQL database, as below:

mysql> CREATE VIEW phonelist AS
    -> SELECT parent.parentID AS ParentID,
    -> ParentPerson.firstName AS ParentFirstName,
    -> ParentPerson.lastName AS  ParentLastName,
    -> ChildPerson.firstName AS PlayerFirstName,
    -> ChildPerson.lastName AS  PlayerLastName,
    -> GuardianHomePhone.homeNumber AS GuardianHomePhone
    -> FROM parent
    -> JOIN player ON (parent.parentID IN (player.motherID, player.fatherID))
    -> JOIN person AS ParentPerson ON (ParentPerson.personID = parent.parentID)
    -> JOIN person AS  ChildPerson ON (ChildPerson.personID = player.playerID)
    -> JOIN addressDetails AS GuardianHomePhone ON (GuardianHomePhone.personID = parent.parentID);

Query OK, 0 rows affected (0.00 sec)

mysql> select * from phonelist;

+----------+-----------------+----------------+-----------------+----------------+-------------------+
| ParentID | ParentFirstName | ParentLastName | PlayerFirstName | PlayerLastName | GuardianHomePhone |
+----------+-----------------+----------------+-----------------+----------------+-------------------+
|        8 | Gregory         | Peck           | Michael         | Peck           | 034871234         |
|        9 | Laura           | Peck           | Michael         | Peck           | 034871234         |
|       10 | Martha          | Petersen       | Matt            | Petersen       | 034724321         |
|       10 | Martha          | Petersen       | Christopher     | Petersen       | 034724321         |
|       11 | Chris           | Michaels       | Richard         | Michaels       | 034791212         |
|       11 | Chris           | Michaels       | Shaun           | Michaels       | 034791212         |
|       12 | Nadine          | Michaels       | Richard         | Michaels       | 034791212         |
|       12 | Nadine          | Michaels       | Shaun           | Michaels       | 034791212         |
|       13 | Barry           | Dackers        | Harry           | Dackers        | 034871996         |
|       14 | Kevin           | Mitchell       | Daniel          | Mitchell       | 034742886         |
|       15 | Rebecca         | Mitchell       | Daniel          | Mitchell       | 034742886         |
+----------+-----------------+----------------+-----------------+----------------+-------------------+
11 rows in set (0.00 sec)

mysql>

Creating this view was a challenge, but the description below is what I am having trouble navigating around:

I also need to add the team each player is in with this view. Because getting the team’s name to match up requires joining 4 tables together, I am having trouble merging things together. I managed to create a separate query that matches players to teams below:

mysql> select person.firstName, person.lastName, team.teamName
    -> from person join player on person.personID = player.playerID
    -> join teamAllocation on person.personID = teamAllocation.playerID
    -> join team on teamAllocation.teamID = team.teamID;

+-------------+----------+------------+
| firstName   | lastName | teamName   |
+-------------+----------+------------+
| Michael     | Peck     | U10 Red    |
| Christopher | Petersen | U10 Red    |
| Richard     | Michaels | U11 Orange |
| Shaun       | Michaels | U9 Yellow  |
| Matt        | Petersen | U11 Orange |
| Harry       | Dackers  | U9 Yellow  |
| Daniel      | Mitchell | U9 Yellow  |
+-------------+----------+------------+
7 rows in set (0.00 sec)

mysql>

The outcome I am visualizing in my head is something like this:

+----------+-----------------+----------------+-----------------+----------------+----------------+-------------------+
| ParentID | ParentFirstName | ParentLastName | PlayerFirstName | TeamName       | PlayerLastName | GuardianHomePhone |
+----------+-----------------+----------------+-----------------+----------------+----------------+-------------------+
|        8 | Gregory         | Peck           | Michael         | U10 Red        | Peck           | 034871234         |
|        9 | Laura           | Peck           | Michael         | U10 Red        | Peck           | 034871234         |
|       10 | Martha          | Petersen       | Matt            | U11 Orange     | Petersen       | 034724321         |
|       10 | Martha          | Petersen       | Christopher     | U10 Red        | Petersen       | 034724321         |
|       11 | Chris           | Michaels       | Richard         | U11 Orange     | Michaels       | 034791212         |
|       11 | Chris           | Michaels       | Shaun           | U9 Yellow      | Michaels       | 034791212         |
|       12 | Nadine          | Michaels       | Richard         | U11 Orange     | Michaels       | 034791212         |
|       12 | Nadine          | Michaels       | Shaun           | U9 Yellow      | Michaels       | 034791212         |
|       13 | Barry           | Dackers        | Harry           | U9 Yellow      | Dackers        | 034871996         |
|       14 | Kevin           | Mitchell       | Daniel          | U9 Yellow      | Mitchell       | 034742886         |
|       15 | Rebecca         | Mitchell       | Daniel          | U9 Yellow      | Mitchell       | 034742886         |
+----------+-----------------+----------------+-----------------+----------------+----------------+-------------------+

If anyone can help me on this I would be very grateful. For those of you that want to test queries with the data I have put the schema (DDL) and data (DML)scripts (into one “paste”) at http://pastebin.com/S4iJyJUh.

Also, if anyone thinks there is a better way I can do the view, let me know.

  • 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-06-03T09:00:35+00:00Added an answer on June 3, 2026 at 9:00 am

    You’re almost there, you just need to combine the two queries.

    CREATE VIEW phonelistWithTeams AS
    SELECT parent.parentID AS ParentID,
      ParentPerson.firstName AS ParentFirstName,
      ParentPerson.lastName AS  ParentLastName,
      ChildPerson.firstName AS PlayerFirstName,
      ChildPerson.lastName AS  PlayerLastName,
      team.teamName AS TeamName,
      GuardianHomePhone.homeNumber AS GuardianHomePhone
    FROM parent
      JOIN player ON (parent.parentID IN (player.motherID, player.fatherID))
      JOIN person AS ParentPerson ON (ParentPerson.personID = parent.parentID)
      JOIN person AS  ChildPerson ON (ChildPerson.personID = player.playerID)
      JOIN addressDetails AS GuardianHomePhone ON (GuardianHomePhone.personID = parent.parentID)
      JOIN teamAllocation ON (ChildPerson.personID = teamAllocation.playerID)
      JOIN team ON (teamAllocation.teamID = team.teamID);
    

    Running SELECT * FROM phonelistWithTeams will give you

    +----------+-----------------+----------------+-----------------+----------------+------------+-------------------+
    | ParentID | ParentFirstName | ParentLastName | PlayerFirstName | PlayerLastName | TeamName   | GuardianHomePhone |
    +----------+-----------------+----------------+-----------------+----------------+------------+-------------------+
    |        8 | Gregory         | Peck           | Michael         | Peck           | U10 Red    | 034871234         |
    |        9 | Laura           | Peck           | Michael         | Peck           | U10 Red    | 034871234         |
    |       10 | Martha          | Petersen       | Matt            | Petersen       | U11 Orange | 034724321         |
    |       10 | Martha          | Petersen       | Christopher     | Petersen       | U10 Red    | 034724321         |
    |       11 | Chris           | Michaels       | Richard         | Michaels       | U11 Orange | 034791212         |
    |       11 | Chris           | Michaels       | Shaun           | Michaels       | U9 Yellow  | 034791212         |
    |       12 | Nadine          | Michaels       | Richard         | Michaels       | U11 Orange | 034791212         |
    |       12 | Nadine          | Michaels       | Shaun           | Michaels       | U9 Yellow  | 034791212         |
    |       13 | Barry           | Dackers        | Harry           | Dackers        | U9 Yellow  | 034871996         |
    |       14 | Kevin           | Mitchell       | Daniel          | Mitchell       | U9 Yellow  | 034742886         |
    |       15 | Rebecca         | Mitchell       | Daniel          | Mitchell       | U9 Yellow  | 034742886         |
    +----------+-----------------+----------------+-----------------+----------------+------------+-------------------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.