Set MySQL DECIMAL with accuracy of 10 digits after the comma?

Ankith Reddy
Updated on 30-Jul-2019 22:30:24

522 Views

As you know the DECIMAL() method takes two parameter. The first parameter tells about the total number of digits and second parameter tells about number of digits after decimal point. Therefore, if you use DECIMAL(10, 10) that means you can use only 10 fractional digit.For Example: Store 0.9999999999 with DECIMAL(20, 10).To understand what we discussed above, let us create a table. The query to create a table is as follows:mysql> create table Decimal_Demo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Price DECIMAL(20, 10), -> PRIMARY KEY(Id) ... Read More

Delete more than one rows from a table using id in MySQL?

Anvi Jain
Updated on 30-Jul-2019 22:30:24

1K+ Views

You can use IN statement to delete more than one rows from a table using id in MySQL. The syntax is as follows −delete from yourTableName where yourColumnName in(value1, value2, .....valueN);To understand the above syntax, let us create a table. The following is the query to create a table.mysql> create table DeleteManyRows    −> (    −> Id int,    −> Name varchar(200),    −> Age int    −> ); Query OK, 0 rows affected (3.35 sec)Insert some records in the table with the help of insert command. The query is as follows −mysql> insert into DeleteManyRows values(1, 'John', 23); ... Read More

Create a procedure in MySQL with parameters?

Chandu yadav
Updated on 30-Jul-2019 22:30:24

4K+ Views

You can create a parameter using IN and OUT. IN is used to take input parameter and OUT can be used for output.The syntax is as followsDELIMITER // CREATE PROCEDURE yourProcedureName(IN yourParameterName dataType, OUT yourParameterName dataType ) BEGIN yourStatement1; yourStatement2; . . N END; // DELIMITER ;First, we will create a table. The query to create a table is as followsmysql> create table SumOfAll -> ( -> Amount int -> ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command. The query ... Read More

What are the career options for a post graduate in biotech?

Madhuparna
Updated on 30-Jul-2019 22:30:24

193 Views

Although India does not yet have a good setup for Biotechnology, there are career options galore after you have completed your post graduate in biotech. Whether you have completed your post-graduation in Biotech from the reputed institutes in India such as, Tata Institute of Fundamental Research or Indian Institute of Science, or from any university situated abroad, it’s a high-level training that matters.According to industry experts like Dr. Yusuf Deeni, post completion of Masters in Biotechnology, one can find employment in biotech companies or can even pursue Ph.D.One can also be a part of biofuels, healthcare, cleantech and industrial biotechnology.For ... Read More

Returning a value even if there is no result in a MySQL query?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

9K+ Views

You can use IFNULL() function from MySQL to return a value even if there is not result. Let us create a table. Te query to create a table.mysql> create table IfNullDemo    −> (    −> Id int,    −> Name varchar(100)    −> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table with the help of insert command. The query is as follows −mysql> insert into IfNullDemo values(1, 'John'); Query OK, 1 row affected (0.18 sec) mysql> insert into IfNullDemo values(200, 'Sam'); Query OK, 1 row affected (0.21 sec) mysql> insert into IfNullDemo ... Read More

Changing year in MySQL date?

Arjun Thakur
Updated on 30-Jul-2019 22:30:24

5K+ Views

To change the year in MySQL date, you need to use DATE_FORMAT() function with UPDATE command. The syntax is as follows.UPDATE yourTableName SET yourDateColumnName = DATE_FORMAT(yourDateColumnName ,'yourYearValue-%m-%d');To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table ChangeYear    -> (    -> id int not null auto_increment,    -> ArrivalTime date,    -> PRIMARY KEY(id)    -> ); Query OK, 0 rows affected (0.83 sec)Insert some records in the table using insert command −mysql> insert into ChangeYear(ArrivalTime) values(date_add(now(), interval -2 year)); Query OK, 1 row affected, 1 warning ... Read More

What happens if it rains in the desert?

Samrat T
Updated on 30-Jul-2019 22:30:24

879 Views

There are many interesting answers to this question. But I found one very fascinating and amazing phenomenon. When it rains suddenly in the Atacama desert in Chile, which is the driest non-polar desert on Earth, there will be a sudden spur of life in the desert.If the desert gets heavy rainfall during their spring season which is October and November, there will be a sudden bloom of the flowers ‘hibernating’ beneath its surface. It fills the entire desert with an explosion of color by the flowers coming to their full bloom which is eagerly waiting for the rain, leaving the place ... Read More

How to find nth highest value of a MySQL column?

Chandu yadav
Updated on 30-Jul-2019 22:30:24

748 Views

To find the nth highest value of a column, you need to use ORDER BY DESC with LIMIT clause. If you want the second highest value of a column, use the below syntax:SELECT *FROM yourTableName ORDER BY DESC yourColumnName LIMIT 1, 1;If you want the fourth highest value of a column, use the below syntax:SELECT *FROM yourTableName ORDER BY DESC yourColumnName LIMIT 3, 1;If you want the first highest value of a column, use the below syntax:SELECT *FROM yourTableName ORDER BY DESC yourColumnName LIMIT 1;As discussed in the above syntax, you need to change only in LIMIT clause. To understand ... Read More

Delete all the records from a MySQL table?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:24

1K+ Views

To delete all the records from a MySQL table, you can use the TRUNCATE statement.The syntax is as follows −TRUNCATE TABLE yourTableName;The above syntax deletes all the records from the table. To understand the above syntax, let us create a table. The following is the query to create a table −mysql> create table DeleteAllFromTable −> ( −> PersonId int, −> PersonName varchar(200) −> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table with the help of insert command.The query is as follows −mysql> insert ... Read More

How to set sql_mode permanently in MySQL?

George John
Updated on 30-Jul-2019 22:30:24

1K+ Views

If you are using Windows Operating System, check your directory my.cnf or my.ini file.mysql> select @@datadir;The following is the output+---------------------------------------------+ | @@datadir | +---------------------------------------------+ | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ | +---------------------------------------------+ 1 row in set (0.00 sec)Reach the above location ‘C:\ProgramData\MySQL\MySQL Server 8.0\Data\”. The screenshot is as follows for my.cnf fileOpen the my.cnf file and write the sql_mode="TRADITIONAL". The syntax is as followssql_mode="TRADITIONAL".After that start your server once again.

Advertisements