Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Table Name: STUDENT snum sname course year gender bdate 200912345 Angus Maximus

ID: 3920312 • Letter: T

Question

Table Name: STUDENT

snum

sname

course

year

gender

bdate

200912345

Angus Maximus

Information Technology

3

M

1993-05-04

200912333

Prism Queen

Information Technology

3

F

1994-02-07

200820111

Ice Crown

Computer Science

4

F

1992-08-01

200811101

Valesti Knight

Information Technology

4

M

1992-06-08

201035600

Surge Seoul

Computer Science

2

M

1995-09-12

201055558

Dark Savior

Computer Engineering

0

1994-12-04

201165844

PyrusLyllwin

Computer Science

1

F

1995-10-10

5.
What is the output of the code below?
$q = mysql_query("SELECT DISTINCT(course) FROM student WHERE gender='F'");
$r = mysql_affected_rows();
echo $r;
-OR-
$q = mysqli_query("SELECT DISTINCT(course) FROM student WHERE gender='F'", $dbconnect);
$r = mysqli_affected_rows();
echo $r;

1

2

3

4

6.
What is the output of the code below?
$q = mysql_query("SELECT sname FROM student WHERE course='Computer Science' ORDER BY year");
$r = mysql_result($q,2);
echo $r;
-or-
$q = mysqli_query("SELECT sname FROM student WHERE course='Computer Science' ORDER BY year", $dbconnect);
$r = mysqli_result($q,2);
echo $r;

Prism Queen

Ice Crown

Surge Seoul

PyrusLyllwin

7.
What is the output of the code below?
$q = mysql_query("SELECT MAX(course) FROM student HAVING MAX(year)");
$r = mysql_result($q,0);
-or-
$q = mysqli_query("SELECT MAX(course) FROM student HAVING MAX(year)", $dbconnect);
$r = mysqli_result($q,0);

Computer Engineering

Computer Science

Information Technology

Error

snum

sname

course

year

gender

bdate

200912345

Angus Maximus

Information Technology

3

M

1993-05-04

200912333

Prism Queen

Information Technology

3

F

1994-02-07

200820111

Ice Crown

Computer Science

4

F

1992-08-01

200811101

Valesti Knight

Information Technology

4

M

1992-06-08

201035600

Surge Seoul

Computer Science

2

M

1995-09-12

201055558

Dark Savior

Computer Engineering

0

1994-12-04

201165844

PyrusLyllwin

Computer Science

1

F

1995-10-10

Explanation / Answer

5.

Output

Information Technology

Computer Science

Explanation:This query selects the distinct courses taken by female students.

6.  

Output

PyrusLyllwin

Surge Seoul

Ice Crown

Explanation:This query selects the name of students who have taken 'Computer Science' course in the order of increasing year.

7.  

Output

Information Technology

Explanation:This query selects the course with maximum length taken by students with maximum year.

NOTE: The last query seems incorrect to me. in my opinion, this query should give you error.