Review: Show All The Information About Every Student Including Phones But Cities
Review: Show All The Information About Every Student Including Phones But Cities
Review: Show All The Information About Every Student Including Phones But Cities
SELECT *
FROM student_information,studentphone
WHERE student_information.reg = studentphone.reg;
14. show all the information about every student including city but phones
SELECT *
FROM student_information,city
WHERE student_information.postal_code = city.postal_code;
15. Show all the information content in the database about the student with dni
= '12345678A' (do not show marks)
SELECT *
FROM student_information,city,studentphone
WHERE
student_information.postal_code = city.postal_code
AND student_information.reg = studentphone.reg
AND dni='12345678A';
16. Show students with phone
SELECT reg
FROM studentphone
WHERE phone IS NOT NULL;
SELECT *
FROM student_information,studentphone
WHERE student_information.reg=studentphone.reg
AND phone IS NOT NULL;
17. Show students' name without phone
SELECT name
FROM student_information,studentphone
WHERE student_information.reg=studentphone.reg
AND phone IS NULL;
18. Show reg and name from all the student that are living in London and are
SELECT *
FROM student_information
WHERE name LIKE 'Ja%';
20. Show all the students whose name ends with 'as'
SELECT *
FROM student_information
WHERE name LIKE '%as';
21. Show all the students whose name has the string 'vi' in his name
SELECT *
FROM student_information
WHERE name LIKE '%vi%';
22. Show all the phones that starts with '96'
SELECT *
FROM studentphone
WHERE phone LIKE '96%';
23. Show all the phones that do NOT starts with '965'
SELECT *
FROM studentphone
WHERE phone NOT LIKE '965%';
24. Show all the phones that do NOT ends with '00'
SELECT *
FROM studentphone
WHERE phone NOT LIKE '%00';
25. Show all the phones that has this string inside: '00'
SELECT *
FROM studentphone
WHERE phone LIKE '%00%';
26. Show all the phones that starts with '96', then has a undefined number and
35. Show the name and age for those students that his age has more than one
digit.
SELECT name,age
FROM student_information
WHERE LENGTH(age)>1;
o
SELECT name,age
FROM student_information
WHERE age>=10;
36. Use 'SUBSTRING(str,n) and SUBSTRING(str,n,m) in two queries. First of
all, look for it to get more information in the reference's manual (string
functions). Explain how does it works.
- select the first 5 characters of every student name
SELECT substring(name,1,5) FROM student_information;
- select the last 5 characters of every student name
SELECT substring(name,-5) FROM student_information;
20;
SELECT postal_code, max(reg) AS max_reg, min(reg) AS min_reg
FROM student_information
WHERE age>20
GROUP BY postal_code;