Concatenating NULL
CREATE TABLE myTable ( id INT, string varchar(100) DEFAULT NULL ); INSERT INTO myTable (id, string) VALUES (1, "First"), (2, NULL); UPDATE myTable SET string = CONCAT(id, " has the value ", string); SELECT * FROM myTable;
What is the output?
Show Answer ▼
Alias
What would result from the following?
CREATE TABLE my_table ( id INT ); INSERT INTO my_table (id) VALUES (2.9), (3), (3.4), (3.9), (4); SELECT * FROM my_table AS m WHERE my_table.id > 3;
Truncation
Assume the following has completed correctly:
CREATE TABLE test ( charField varchar(5) );
What is the end difference between the following two statements?
INSERT INTO test (charField) VALUES ("123456");
INSERT INTO test (charField) VALUES ("12345 ");
Alias
What would result from the following?
CREATE TABLE my_table (
id INT
);
INSERT INTO my_table (id) VALUES (2.9), (3), (3.4), (3.9), (4);
SELECT * FROM my_table AS m WHERE my_table.id > 3;
Show Answer ▼
Passwords
Assume the following have completed:
GRANT ALL ON test1.* TO 'johnQ'@'localhost' IDENTIFIED BY 'pass1'; GRANT ALL ON test2.* TO 'johnQ'@'localhost' IDENTIFIED BY 'pass2';
User johnQ has a query that joins tables from test1 to tables from test2. How should he log in?
a) Using 'pass1'.
b) Using 'pass2'.
c) Using 'pass1' and 'pass2', separated by a colon.
d) It can't be done; he must change the two passwords to match.
e) Other (explain)
Show Answer ▼
Static Variable Variables
<?php
class A {
static function b() {
echo "It works\n";
}
}
$theClass = "A";
$x = new $theClass;
/* Are any of the following legal? Which? */
A::b();
$x->b();
$theClass::b();
?>
Distinct Count
SELECT COUNT(DISTINCT someField) FROM someTable; SELECT DISTINCT someField FROM someTable;
T/F: The value returned by the first will always equal the number of rows returned by the second.
Show Answer ▼
Form Names
Given the following page:
<form> <input type="radio" name="BT.123" value="active" /> <input type="radio" name="BT.123" value="inactive" /> <input type="submit" value="Submit" /> </form> <?php echo "GET: ", $_GET['BT.123']; echo "POST: ", $_POST['BT.123']; echo "REQUEST: ", $_REQUEST['BT.123']; ?>
Assume the "inactive" button is checked and the form is submitted. What is the output?
Show Answer ▼
Unique Index
If I run the following, what will happen?
CREATE TABLE myTable (someField int, UNIQUE (someField)); INSERT INTO myTable VALUES (null); INSERT INTO myTable VALUES (NULL);