Login|Contact Us
Question and Answer

Programming

Ask a Programming Question, Get an Answer ASAP!

  • Ask A Question
  • Browse Answers
  • Meet The Experts
  • How JustAnswer Works

SQL Query Note there are no Primary or foreign keys to be available

 
jatechexpert's Avatar
  • Answered by:jatechexpert
  • Computer Software Engineer
  • Positive Feedback: 96.8 %
  • Accepted Answers: 1285
Verified Expert
in Programming

Recent Feedback

Positive
Great Help! Will use again!
Positive
Type your review here...
Positive
great job
Positive
Awesome, thank you! I really appreciate your quick response and the solution.
Positive
Work was excellent and will recommend to everyone who needs programming help.
Positive
nice job
Positive
Great! Thank you!
Positive
Fast response and quality work
Positive
very helpful and did exactly what was asked for
Positive
Thanks

Customer Question

SQL Query Note there are no Primary or foreign keys to be available to use in these sql querys
Child Table toy table with a data Mapping table.

CHILD

Child_id Child_name
1 Lucy
2 Linus
3 Ted
4 Bill
5 Fred
6 Charlie
7 Tom
Mike
sally
------------------------------
Toy
Toy_id Toy_name
1 ball
2 kite
3 tennis
4 football
5 basketball
6 boat
7 hockey
8 sail
9 horse
marbles
--------------------------------------------------

Mapping Table
Child_id Toy_ID
1 1
1 2
1 3
2 4
2 4
2 7
4 7
4 1
7 2
6 7
6 7





Questions:
Need to confirm if I am on the right track and need help with 3 4

1: List “All” children and All their toys.

A) SELECT * child_name , toy_name FROM MAPPING FULL OUTER JOIN TOY
ON child.child_ID = toys.toys_ID
FULL OUTER JOIN ON CHILD
Child.Child.ID = Toy.Toy.id;

or
SELECT * Child, Toy;

or
SELECT * child_name, toy_name FROM CHILD INNER JOIN TOYS ON child.child_ID = Toys.Toys_ID;
'(but I think I need the Mapping table)

_______________________________________________________________________
2: Sum the # of Toys for each Child

SELECT * child.child_id sum(child_ID) as ‘ Total Toys’ FROM Mapping Table JOIN
_______________________________________________________________________
3: List all children with 3 or more toys


NOT SURE

_______________________________________________________________________
4: List all children with 3 toys

Not sure

 

Optional Information:
Language (or Software): SQL
Browser (if necessary): IE

Already Tried:
: List “All” children and All their toys. A) SELECT * child_name , toy_name FROM MAPPING FULL OUTER JOIN CHILD ON child.child_ID = toys.toys_ID FULL OUTER JOIN ON TOY ON child.child_ID = toys.toys_ID;

Submitted: 326 days and 7 hours ago.
Category: Programming
Value: $59
Status: CLOSED
Picture
Expert:  jatechexpert replied 326 days and 7 hours ago.

hi

thanks for using justAnswer.com

are you using SQL server or any other

Customer replied 326 days and 7 hours ago.

Just regular sql at the command level

Picture
Expert:  jatechexpert replied 326 days and 7 hours ago.

hi

let me check this
when you need this

Customer replied 326 days and 7 hours ago.

Okay

Picture
Expert:  jatechexpert replied 326 days and 7 hours ago.

hi

when you need these answers

Customer replied 326 days and 7 hours ago.

any time today is fine

Picture
Expert:  jatechexpert replied 326 days and 6 hours ago.

hi

ok

you check these by 9pm

Picture
Expert:  jatechexpert replied 326 days and 6 hours ago.

hi

for the second one

is it sum the # XXXXX Toys for each Child

or is it Number of Toys for each child

Customer replied 326 days and 6 hours ago.

actually its both

1) sum the # XXXXX toys for each child.. whixh is really the same you just worded it differently.

To Clarify. I need the number of toys (the count) for each child. How many toys does each child have

Picture
Expert:  jatechexpert replied 326 days and 6 hours ago.

hi

ok i will do this

Customer replied 326 days and 6 hours ago.

thanks

Picture
Expert:  jatechexpert replied 326 days and 6 hours ago.

hi

ok then

Picture
Expert:  jatechexpert replied 326 days and 3 hours ago.

hi

here is the answer link below

http://ge.tt/6mS2kZJ/v/0

check them first
hope this helps

Customer replied 326 days and 3 hours ago.

For the first question:

1: List "All" children and All their toys.

Can you provide he sql which list only the children with toys

2. I am not sure if this is correct ie

select CHILD.Child_name, count(Mapping Table.Toy_ID) From Mapping Table,CHILD where Mapping Table.Child_id=CHILD.Child_id group by Mapping Table.Child_id;

...Mapping Table, CHILD

you have a , after Mapping Table and then begin with the CHILD table do you mean a period .

Picture
Expert:  jatechexpert replied 326 days and 3 hours ago.

hi

hi

1. try this

select CHILD.Child_name, Toy.Toy_name From CHILD,Toy, Mapping Table where Mapping Table.Child_id=CHILD.Child_id AND Mapping Table.Toy_id=Toy.Toy_id;

2.
Here select from two tables Mapping Table and CHILD
you want to count the number of toys for each child
so get child name from the child table and number of toys from mapping table for each child and join on child id from mapping table and child table

hope this helps

Customer replied 326 days and 3 hours ago.

thank you I have to go to a meeting but as soon as I get back I will review.

Thank you for your help much appreciated

Picture
Expert:  jatechexpert replied 326 days and 3 hours ago.

hi


you check it

if you are satisfied, don't forget to click on Accept button

i will be offline after 3 hours

if you need anything more, i will contact after coming back

Customer replied 325 days and 21 hours ago.

I am sure its fine I wanted to review tommorrow is their a time limit. Meaning is it okay to spend tommorrow reviewing and then sign off. I

Customer replied 325 days and 20 hours ago.

I just wanyted o followup on your syntax and your comments...............................

try this

select CHILD.Child_name, Toy.Toy_name From CHILD,Toy, Mapping Table where Mapping Table.Child_id=CHILD.Child_id AND Mapping Table.Toy_id=Toy.Toy_id;

2.
Here select from two tables Mapping Table and CHILD
you want to count the number of toys for each child
so get child name from the child table and number of toys from mapping table for each child and join on child id from mapping table and child table

hope this helps.............................................................

1) You substiute WHERE for ON.

I assume they are the same???

2) You don't use INNER JOIN or OUTER JOIN when writing the SQL pe your comments and Join on child_id from Mapping table ... ir the SQL statement INNER JOIN and OUTER JOIN not necessary?

Picture
Expert:  jatechexpert replied 325 days and 19 hours ago.

hi

i will re change it again

Customer replied 325 days and 8 hours ago.

Okay great.
it would be good to see how different the same sql querys would look for questions 1 - 4 using ON and inner outer and full JOINS

Picture
Expert:  jatechexpert replied 325 days and 8 hours ago.

hi

i will do like this

Customer replied 325 days and 7 hours ago.

thank you

Picture
Expert:  jatechexpert replied 325 days and 7 hours ago.

hi

you check after 4 hours

i will send it

Customer replied 325 days and 7 hours ago.

okay thanks again

Picture
Expert:  jatechexpert replied 325 days and 7 hours ago.

hi
ok then

Customer replied 325 days and 7 hours ago.

Thank you

Picture
Expert:  jatechexpert replied 325 days and 7 hours ago.

hi

see you

Picture
Expert:  jatechexpert replied 325 days and 6 hours ago.

hi

here is the link below

http://ge.tt/9j5z6cJ/v/0

hope this helps

3 and 4 better to use these queries for the output

Customer replied 324 days and 22 hours ago.

I just need to confirm that we can wrtite the SQL for question 1 and Question #2 two different ways and get the same output results. Question #3 and #4 should remain the same

Thanks again fro your help

1: List
"All" children and All their toys.

Answer 1A:
SELECT * Child, Toy;

Answer 1B:

SELECT CHILD.Child_name, Toy.Toy_name FROM CHILD, Toy, Mapping Table WHERE Mapping Table, Child_id = CHILD.Child_id AND Mapping Table.Toy_id = Toy.Toy_id;

Answer 1C:

SELECT
CHILD.Child_name, Toy.Toy_name FROM CHILD LEFT OUTER
JOIN
Mapping Table ON
CHILD.Child_id INNER JOIN Toy ON Toy.Toy_id = Mapping Table.Toy_id

_____________________________________________________________________

 

2: : Sum
the # XXXXX Toys for each Child

Anwer 2A:
SELECT
CHILD.Child_name, COUNT(Mapping
Table.Toy_ID)FROM
Mapping Table, CHILD WHERE
Mapping Table.Child_id = CHILD.Child_id GROUP BY Mapping
Table.Child_id;

 

Answer 2B:

SELECT
CHILD.Child_name, COUNT
(Mapping Table.Toy_ID) FROM
Mapping Table INNER JOIN
CHILD ON
Mapping
Table.Child_id = CHILD.Child_id GROUP BY Mapping Table.Child_id;

Picture
Expert:  jatechexpert replied 324 days and 19 hours ago.

hi
ok

Accepted Answer

Picture
Expert:  jatechexpert replied 324 days and 16 hours ago.

hi

here is the answer link below

http://ge.tt/6Dlr0eJ/v/0

hope this helps

Expert TypeComputer Software Engineer
Category: Programming
Pos. Feedback: 96.8 %
Accepts: 1285
Answered: 6/26/2012

Experience: Master of Computer Application plus 5+ year experience in Software development

Ask this Expert a Question >
 
Tweet

7 Programmers are Online Right Now

Ask Your Question Now
Programming Questions Date Submitted
Help with my final assignment for VB 5/9/2013
I am new to C programming, and this is an assignment problem. 5/9/2013
Another programming question for you the link is as follows 5/8/2013
Programming question help the link is as follows for the question 5/8/2013
i dont know programming i create OKPR508211. 5/8/2013
I need a programmer to help me with a couple of questions I 5/7/2013
Design and write a program (VB) that collects the following 5/7/2013
To RajStatements Assume that quest is an integer variable 5/6/2013
I need help on this Java programming problem. I included the 5/5/2013
a java programming question 5/5/2013
RSS
Next 10 >
Ask A Programmer
Type Your Programming Question Here...
characters left:

Top Programming Experts

See More Programmers

In The News

Nbc
Washington Post
New York Times
Cnn
Learn More

How It Works

  • Ask an Expert
  • Get a Professional Answer
  • Ask Followup Questions
  • 100% Satisfaction Guarantee
Learn More
close
Find Expert answers related to your question.
Sign up using email
We will never post anything without your permission.
Already have an account? Sign in

Ask a Programmer

Get a Professional Answer. 100% Satisfaction Guaranteed.
217 Programmers are Online Now
Type Your Programming Question Here...
characters left:
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.
Truste
Contact Us | Terms of Service | Privacy & Security | About Us | Our Network
© 2003-2013 JustAnswer LLC
  • Pearl.com
  • JustAnswer UK
  • JustAnswer Germany
  • JustAnswer Spanish
  • JustAnswer Japan