misheck
08-06-2009, 09:23 AM
I have been asked to answer some simple mysql questions. I have entered the data using PhpMyadmin but I think I have entered it wrongly because I am getting a an empty set on question number 2.I will attempt 3 and 4 by myself but if I need help I will ask here the questions;
MySQL tables...
database.names
id, name
1, Tom
2, Simon
3, Sarah
4, Ann
5, Bernie
database.telephone_nums
id, name_id, telephone_number
1, 2, 01438 234 678
2, 5, 01438 765 890
3, 1, 01438 657 897
database.mobile_nums
id, name_id, mobile_number
1, 1, 07913 452 675
2, 1, 07913 567 890
3, 3, 07913 545 555
1) Generate a single SQL query to return the telephone number for Tom.
2) Generate a single SQL query which returns the names of any people without either a telephone or mobile number stored.
3) Generate a query to return the second and third name from the lists sorted in ascending order. Do not do this by just listing the id numbers.
4) MySQL has the 'LIMIT' command which you probably used in No. 3. MS SQL has only the 'TOP' command instead. Try No. 3 for MS SQL instead.
Hope that makes sense,
My answer to question 2 was SELECT name FROM names, telephone_nums, mobile_nums WHERE mobile_number IS null OR telephone_number IS null;
Its returning any empty set. Here is a print screen of what this query show about my Tables because thats where the error might be. The query is SELECT * FROM names, telephone_nums, mobile_nums;
I have been asked to answer some simple mysql questions. I have entered the data using PhpMyadmin but I think I have entered it wrongly because I am getting a an empty set on question number 2. Here the questions;
MySQL tables...
database.names
id, name
1, Tom
2, Simon
3, Sarah
4, Ann
5, Bernie
database.telephone_nums
id, name_id, telephone_number
1, 2, 01438 234 678
2, 5, 01438 765 890
3, 1, 01438 657 897
database.mobile_nums
id, name_id, mobile_number
1, 1, 07913 452 675
2, 1, 07913 567 890
3, 3, 07913 545 555
1) Generate a single SQL query to return the telephone number for Tom.
2) Generate a single SQL query which returns the names of any people without either a telephone or mobile number stored.
3) Generate a query to return the second and third name from the lists sorted in ascending order. Do not do this by just listing the id numbers.
4) MySQL has the 'LIMIT' command which you probably used in No. 3. MS SQL has only the 'TOP' command instead. Try No. 3 for MS SQL instead.
Hope that makes sense,
My answer to question 2 was SELECT name FROM names, telephone_nums, mobile_nums WHERE mobile_number IS null OR telephone_number IS null;
Its returning any empty set. Here is a print screen of what this query show about my Tables because thats where the error might be. The query is SELECT * FROM names, telephone_nums, mobile_nums;(Its not very clear but every name is being repeated 5 times )[http://img23.imageshack.us/img23/2066/mysqlprint.th.png (http://img23.imageshack.us/i/mysqlprint.png/)
MySQL tables...
database.names
id, name
1, Tom
2, Simon
3, Sarah
4, Ann
5, Bernie
database.telephone_nums
id, name_id, telephone_number
1, 2, 01438 234 678
2, 5, 01438 765 890
3, 1, 01438 657 897
database.mobile_nums
id, name_id, mobile_number
1, 1, 07913 452 675
2, 1, 07913 567 890
3, 3, 07913 545 555
1) Generate a single SQL query to return the telephone number for Tom.
2) Generate a single SQL query which returns the names of any people without either a telephone or mobile number stored.
3) Generate a query to return the second and third name from the lists sorted in ascending order. Do not do this by just listing the id numbers.
4) MySQL has the 'LIMIT' command which you probably used in No. 3. MS SQL has only the 'TOP' command instead. Try No. 3 for MS SQL instead.
Hope that makes sense,
My answer to question 2 was SELECT name FROM names, telephone_nums, mobile_nums WHERE mobile_number IS null OR telephone_number IS null;
Its returning any empty set. Here is a print screen of what this query show about my Tables because thats where the error might be. The query is SELECT * FROM names, telephone_nums, mobile_nums;
I have been asked to answer some simple mysql questions. I have entered the data using PhpMyadmin but I think I have entered it wrongly because I am getting a an empty set on question number 2. Here the questions;
MySQL tables...
database.names
id, name
1, Tom
2, Simon
3, Sarah
4, Ann
5, Bernie
database.telephone_nums
id, name_id, telephone_number
1, 2, 01438 234 678
2, 5, 01438 765 890
3, 1, 01438 657 897
database.mobile_nums
id, name_id, mobile_number
1, 1, 07913 452 675
2, 1, 07913 567 890
3, 3, 07913 545 555
1) Generate a single SQL query to return the telephone number for Tom.
2) Generate a single SQL query which returns the names of any people without either a telephone or mobile number stored.
3) Generate a query to return the second and third name from the lists sorted in ascending order. Do not do this by just listing the id numbers.
4) MySQL has the 'LIMIT' command which you probably used in No. 3. MS SQL has only the 'TOP' command instead. Try No. 3 for MS SQL instead.
Hope that makes sense,
My answer to question 2 was SELECT name FROM names, telephone_nums, mobile_nums WHERE mobile_number IS null OR telephone_number IS null;
Its returning any empty set. Here is a print screen of what this query show about my Tables because thats where the error might be. The query is SELECT * FROM names, telephone_nums, mobile_nums;(Its not very clear but every name is being repeated 5 times )[http://img23.imageshack.us/img23/2066/mysqlprint.th.png (http://img23.imageshack.us/i/mysqlprint.png/)