Use MySQL Date Functions with WHERE Clause

Ankith Reddy
Updated on 22-Jun-2020 05:02:53

2K+ Views

By using the WHERE clause with any of the MySQL date functions, the query will filter the rows based on the condition provided in the WHERE clause. To understand it, consider the data from ‘Collegedetail’ table as followsmysql> Select * from Collegedetail; +------+---------+------------+ | ID   | Country | Estb       | +------+---------+------------+ | 111  | INDIA   | 2010-05-01 | | 130  | INDIA   | 1995-10-25 | | 139  | USA     | 1994-09-25 | | 1539 | UK      | 2001-07-23 | | 1545 | Russia  | 2010-07-30 | +------+---------+------------+ 5 rows in ... Read More

Extract Year and Month from a Date in MySQL

Monica Mona
Updated on 22-Jun-2020 05:01:52

5K+ Views

It can be done with the following three ways in MySQLBy using EXTRACT() function For extracting YEAR and MONTH collectively then we can use the EXTRACT function. We need to provide the YEAR_MONTH as an argument for this function. To understand it, consider the following function using the data from table ‘Collegedetail’ −mysql> Select EXTRACT(YEAR_MONTH From estb) from collegedetail; +-------------------------------+ | EXTRACT(YEAR_MONTH From estb) | +-------------------------------+ |                        201005 | |                        199510 | |             ... Read More

Run MySQL Statements in Batch Mode

varun
Updated on 22-Jun-2020 05:00:18

464 Views

We need to create a .sql file for running MySQL in batch mode. This file will contain the MySQL statements. Suppose I have hh.sql file in which I have written the statement select * from hh. With the help of the following command, we can run this file in batch mode −ExampleC:\Program Files\MySQL\bin>mysql -u root -p gaurav < hh.sql Enter password: *****Outputid 1 2Here Gaurav is the database name that contains the table hh. Whenever you’ll run this command it will ask for the password and then give the output.

Get MySQL Interactive Output Format in Batch Mode

usharani
Updated on 22-Jun-2020 04:59:20

412 Views

We can get the MySQL output format in batch mode with the help of –t option. For example, after running the same query in batch mode with –t option we will get the output like interactive format.ExampleC:\Program Files\MySQL\bin>mysql -u root -p gaurav < hh.sql -t Enter password: *****Output+------+ | id   | +------+ | 1    | | 2    | +------+

Difference Between MySQL Output Formats in Batch and Interactive Modes

Abhinanda Shri
Updated on 22-Jun-2020 04:58:48

129 Views

The default MySQL output would be different if we will run the same query interactively or in batch mode. For example, if we will run the query select * from hh interactively then following would be a format of output −mysql> select * from hh; +------+ | id   | +------+ |  1   | |  2   | +------+ 2 rows in set (0.01 sec)On the other hand, if we will run the same query in batch mode then following would be the format of output −C:\Program Files\MySQL\bin>mysql -u root -p gaurav < hh.sql Enter password: ***** id 1 2

Add Days to Date in MySQL Table

Alankritha Ammu
Updated on 22-Jun-2020 04:57:37

229 Views

Two functions can be used for this purpose and in both the functions we need to provide column name as an argument along with INTERVAL keyword. The functions are as follows −DATE_ADD() functionThe syntax of this function is DATE_ADD(date, INTERVAL expression unit). It can be demonstrated by following the example which uses the data from table ‘collegedetail’ −mysql> Select estb, DATE_ADD(estb, INTERVAL 10 DAY) from collegedetail; +------------+---------------------------------+ | estb | DATE_ADD(estb, INTERVAL 10 DAY)       | +------------+---------------------------------+ | 2010-05-01 | 2010-05-11                      | | 1995-10-25 | 1995-11-04     ... Read More

Check Table Status of Tables in MySQL Database

varma
Updated on 22-Jun-2020 04:56:12

458 Views

We can check the status of tables in a database with the help of show table status statement. For example, in the database named tutorial, by executing this statement we can get the status of tables as follows −mysql> show table status \G*************************** 1. row ***************************            Name: student          Engine: InnoDB         Version: 10      Row_format: Compact            Rows: 0  Avg_row_length: 0     Data_length: 16384 Max_data_length: 0    Index_length: 0       Data_free: 7340032  Auto_increment: NULL     Create_time: 2017-10-24 09:34:29   ... Read More

Set Textarea Content Using jQuery

Arnab Chakraborty
Updated on 21-Jun-2020 17:10:30

3K+ Views

On clicking the tag,the content is dispaying inside the textarea.Example Live Demo    $(document).ready(function () {       $("a").click(function () {          $("#txt1").val("I AM DISPLAYING IN THE TEXTAREA");       });    });     Quires TEXTAREA ::

Get Textarea Content Using jQuery

Arnab Chakraborty
Updated on 21-Jun-2020 17:08:12

721 Views

Here I am using one textarea and one button.The first textarea is used for user input then click the button and display the value in the alert box.Example Live Demo                    $(document).ready(function () {             $("button").click(function () {                var dim = $("#txt").val();                alert(dim);             });          });     Click Here

Count Number of Rows in a Table with jQuery

Arnab Chakraborty
Updated on 21-Jun-2020 17:04:04

1K+ Views

Example Live Demo table        table,th,td {       border:2px solid black;       margin-left:400px;    }    h2 {       margin-left:400px;    }    button {       margin-left:400px;    }            $(document).ready(function () {       $("button").click(function () {          var rowcount = $('table tr').length;          alert("No. Of Rows ::" +rowcount);       });    }); HTML TABLE NAME AGE DD 35 SB 35 AD 5 AA 5 Click Here

Advertisements