31. what is difference between primary key and candidate key?
Primary Key
- are used to uniquely identify each row of the table. A table can have only one primary Key.
Candidate Key
- primary key is a candidate key. There is no difference. By common convention one candidate key is designated as a “primary” one and that key is used for any foreign key references.
32. How do you get the month from a timestamp?
SELECT MONTH(january_timestamp) from tablename;
33. What do % and _ mean inside LIKE statement?
% corresponds to 0 or more characters, _ is exactly one character.
34. If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table?
999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
35. How do you get the current date in Mysql?
SELECT CURRENT_DATE();
36. What is the difference between mysql_fetch_array and mysql_fetch_object?
mysql_fetch_array(): - returns a result row as a associated array, regular array from database.
mysql_fetch_object: - returns a result row as object from database.
37. You wrote a search engine that should retrieve 10 results at a time, but at the same time you’d like to know how many rows there’re total. How do you display that to the user?
SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS();
38. What does this query mean: SELECT user_name, user_isp FROM users LEFT JOIN isps USING (user_id)?It’s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id
39. How do you display the list of database in mysql?
SHOW DATABASES;
40. How do you display the structure of the table?
DESCRIBE table_name;
Share This :
Primary Key
- are used to uniquely identify each row of the table. A table can have only one primary Key.
Candidate Key
- primary key is a candidate key. There is no difference. By common convention one candidate key is designated as a “primary” one and that key is used for any foreign key references.
32. How do you get the month from a timestamp?
SELECT MONTH(january_timestamp) from tablename;
33. What do % and _ mean inside LIKE statement?
% corresponds to 0 or more characters, _ is exactly one character.
34. If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table?
999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
35. How do you get the current date in Mysql?
SELECT CURRENT_DATE();
36. What is the difference between mysql_fetch_array and mysql_fetch_object?
mysql_fetch_array(): - returns a result row as a associated array, regular array from database.
mysql_fetch_object: - returns a result row as object from database.
37. You wrote a search engine that should retrieve 10 results at a time, but at the same time you’d like to know how many rows there’re total. How do you display that to the user?
SELECT SQL_CALC_FOUND_ROWS page_title FROM web_pages LIMIT 1,10; SELECT FOUND_ROWS();
38. What does this query mean: SELECT user_name, user_isp FROM users LEFT JOIN isps USING (user_id)?It’s equivalent to saying SELECT user_name, user_isp FROM users LEFT JOIN isps WHERE users.user_id=isps.user_id
39. How do you display the list of database in mysql?
SHOW DATABASES;
40. How do you display the structure of the table?
DESCRIBE table_name;
0 comments:
Post a Comment