The following questions are based on user defined variables and prepared statements.
1. Assign the firstname and lastname of an employee in two variables and concat the firstname and lastname and store the result in another variable in select statement and print the result.
2. Print the area of a circle by storing the radius in one variable and take ‘pi’ value as 3.14 and the result in another variable.
3. Create a table InputForm with the following fields
Firstname, Lastname, email_id, mobilenumber.
[insert atleast 10 records]
4. Prepare a statement to insert the values in to the above table.
5. Execute the above statement and print the records of the InputForm table.
6. Create a statement to display the records of the InputForm table, by taking the mobilenumber in the where clause.
7. Store the table ‘InputForm’ in a variable. for ex: @table.
8. concat the ‘select * from ‘ with @table and store the result in another variable. for ex: @statement2
9. Prepare the statement with the @statement2.
10. Execute the @statement2 with out any variables.
11. Drop the @statement2.
12. prepare a statement with the following query:
‘SELECT productCode, productName
WHERE productCode = ?’;
Take the sample database, I have given.
13. Execute the prepared statement with different productCodes [ atleast 3].
14. Display the list of prepared statement and the user_defined variables currently you have in the MySQL session.