varun

varun

65 Articles Published

Articles by varun

Page 3 of 7

Why is it necessary to declare NOT FOUND handler while using MySQL cursor?\\n

varun
varun
Updated on 22-Jun-2020 2K+ Views

We must have to declare NOT FOUND handler while working with MySQL cursor because it handles the situation when cursor could not find any row. It also handles the situation when the cursor reaches the end of the row because every time we call FETCH statement the cursor finds to attempt the next row in the result set. Following is the syntax to declare NOT FOUND handler −DECLARE CONTINUE HANDLER FOR NOT FOUND SET var_name = value;Here var_name is the name of any variable and value would be the value of that variable. For example, we can declare it as ...

Read More

How can local variables be used in MySQL stored procedure?

varun
varun
Updated on 22-Jun-2020 532 Views

Local variables are those variables that are declared within the stored procedure. They are only valid within the BEGIN…END block where they are declared and can have any SQL data type. To demonstrate it, we are creating the following procedure −mysql> DELIMITER // ; mysql> Create Procedure Proc_Localvariables()    -> BEGIN    -> DECLARE X INT DEFAULT 100;    -> DECLARE Y INT;    -> DECLARE Z INT;    -> DECLARE A INT;    -> SET Y = 250;    -> SET Z = 200;    -> SET A = X+Y+Z;    -> SELECT X, Y, Z, A;    -> ...

Read More

CSS text-emphasis property

varun
varun
Updated on 20-Jun-2020 164 Views

Used to emphasis text and color. Let us see an example:text-emphasis: text-emphasis-style text-emphasis-color;Here,text-emphasis-color: foreground color of the emphasis marktext-emphasis-style: emphasis marks on the element's text

Read More

How can I get the list of columns from a table in the other database than we are currently using?

varun
varun
Updated on 20-Jun-2020 133 Views

It can be done with the SHOW COLUMNS statement. Its Syntax would be as follows −SyntaxSHOW COLUMNS FROM db_name.tab_nameHere, tab_name is the name of the table from which we want to see the list of columns.Db_name is the name of the database, in which the table is storedExampleIn the example we are currently using the database ‘query’ and getting the list of columns from table named ‘arena’ stored in mysql ‘database’ −mysql> SHOW COLUMNS FROM mysql.arena\G *************************** 1. row ***************************   Field: id    Type: int(10) unsigned zerofill    Null: NO     Key: PRI Default: NULL   Extra: auto_increment ...

Read More

In MySQL, how can we maintain data-driven table relationship using joins?

varun
varun
Updated on 20-Jun-2020 232 Views

Actually, sometimes we can avoid data-driven relationships in tables and we need to join them. It can be done with the help of CASE statement in the SELECT list to handle the joining possibilities. To understand it, we are taking the example of three data-driven tables namely ‘Student_Detail’ which have the following data −mysql> Select * from student_detail; +----+---------+ | Id | Name    | +----+---------+ | 1  | Harshit | | 2  | Rahul   | | 3  | Aarav   | +----+---------+ 3 rows in set (0.00 sec)Now, we have the three tables namely ‘Student_Harshit’, ‘Student_Rahul’, ‘Student_Aarav’ which ...

Read More

How can we upload data into multiple MySQL tables by using mysqlimport?

varun
varun
Updated on 20-Jun-2020 459 Views

With the help of mysqlimport we can upload data into multiple MySQL tables. It is illustrated in the example below −ExampleSuppose we want to upload the following data from two data files namely student1_tbl.txt −1     Saurav     11th 2     Sahil      11th 3     Digvijay   11thAnd House.txt1   Furniture 2   Television 3   RefrigeratorFollowings are MySQL tables into which we want to upload the above data −mysql> DESCRIBE Student1_tbl; +--------+-------------+------+-----+---------+-------+ | Field  | Type        | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | RollNo | int(11) ...

Read More

CSS3 font combinations

varun
varun
Updated on 20-Jun-2020 159 Views

CSS3 has adapted font combinations technology. In here, if the browser does not support the first font then it tries the next font.Let us see an example of Sans-Serif fonts −

Read More

On passing an out-of-range value in UNIX_TIMESTAMP() or FROM_UNIXTIME() function, what MySQL will return?

varun
varun
Updated on 20-Jun-2020 403 Views

When we pass an out-of-range value in UNIX_TIMESTAMP, MySQL returns 0. The valid range of value is same as for the TIMESTAMP data type.Examplemysql> Select UNIX_TIMESTAMP('1969-01-01 04:05:45'); +---------------------------------------+ | UNIX_TIMESTAMP('1969-01-01 04:05:45') | +---------------------------------------+ |                         0             | +---------------------------------------+ 1 row in set (0.00 sec)When we pass an out-of-range value in FROM_UNIXTIME, MySQL returns NULL. The valid range of values is same as for the INTEGER data type.Examplemysql> Select FROM_UNIXTIME(2147483648); +---------------------------+ | FROM_UNIXTIME(2147483648) | +---------------------------+ | NULL                      | +---------------------------+ 1 row in set (0.00 sec)

Read More

How can we insert current date and time automatically on inserting values in other columns in MySQL?

varun
varun
Updated on 19-Jun-2020 2K+ Views

In MySQL, we can insert the current date and time automatically to a column on inserting the values in another column by declaring that column as DEFAULT CURRENT_TIMESTAMP.Examplemysql> Create table testing    -> (    -> StudentName varchar(20) NOT NULL,    -> RegDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP    -> ); Query OK, 0 rows affected (0.49 sec)Above query will create a table ‘testing’ with a column named StudentName and other column named ‘RegDate’ declared as DEFAULT CURRENT_TIMESTAMP. Now, on inserting the values i.e. names in StudentName column, the current date and time will be inserted in the other column automatically.mysql> Insert ...

Read More

How to count the number of occurrences of a character in a string in JavaScript?

varun
varun
Updated on 17-Jun-2020 860 Views

To count the number of occurrences of a character in a string, try to run the following code − Example                  function displayCount() {          setTimeout(function() {            var str = document.getElementById('str1').value;            var letter = document.getElementById('letter1').value;            letter = letter[letter.length-1];            var lCount;            for (var i = lCount = 0; i < str.length; lCount += (str[i++] == letter));            document.querySelector('p').innerText = lCount;            return lCount;          }, 50);        }            Enter String:      Enter Letter:      Click for Result      result=    

Read More
Showing 21–30 of 65 articles
« Prev 1 2 3 4 5 7 Next »
Advertisements