Sumita Arora Solution

Consider the two fields B_date, which stores the birth date and j_date, which stores the joining date of an employee. Write commands to find out and display the approximate age of an employee as on today.

SELECT YEAR(CURRENT_DATE()) – YEAR(B_date()) AS ‘Age’;

Consider the two fields B_date, which stores the birth date and j_date, which stores the joining date of an employee. Write commands to find out and display the approximate age of an employee as on today. Read More »

6. If Str = “INFORMATION PRACTICES…” and Str1 = “… FOR CLASS XI” write commands to print the output as ‘information practices’ for class xi’

Ans:CONCAT( CONCAT( LCASE( TRIM( TRAILING ‘.’ FROM ‘INFORMATION PRACTICE…’)) . ‘ ‘ ).LCASE( TRIM( LEADING ‘.’ FROM ‘…FOR CLASS XI’)));

6. If Str = “INFORMATION PRACTICES…” and Str1 = “… FOR CLASS XI”write commands to print the output as ‘information practices’ for class xi’ Read More »

10. What additional argument do you need to specify in to_sql() so that old data of MySQL table is retained ?
11. If query is string storing an SQL statement. Write statements so that the data is fetched based on query from SQL database Mydata.

Ans 10 :we can use if_exists = ‘append’ argument to retain old data of table. Syntax:<dataframe_object>.to_sql( “table_name”, connection_object, if_exists = “append”)Example:df.to_sql(“book”, con, if_exists = “append”) Ans 11 :import pandas as pdimport mysql.connector as sqltcon = sqlt.connect (host = “localhost”, user = “root”, passwd = “yourpassword” , database = “yourdatabasename”)cursor = con.cursor()qry = “select * from

10. What additional argument do you need to specify in to_sql() so that old data of MySQL table is retained ?
11. If query is string storing an SQL statement. Write statements so that the data is fetched based on query from SQL database Mydata.
Read More »

error: Content is protected !!