Chandu yadav has Published 1091 Articles

Grab where current date and the day before with MySQL?

Chandu yadav

Chandu yadav

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

2K+ Views

You can grab the current date with CURDATE() and the day before with MySQL using DATE_SUB() with INTERVAL 1 DAY. The syntax is as follows:SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY);The syntax is as follows to get curdate and the day before with date_sub().SELECT *FROM yourTableName WHERE yourColumnName = CURDATE() OR yourColumnName ... Read More

How can I stop a running MySQL query?

Chandu yadav

Chandu yadav

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

715 Views

In order to stop a running MySQL query, we can use the KILL command with process id. The syntax is as follows −kill processId;Or you can stop a running MySQL query with the help of below syntax −call mysql.rds_kill(queryId);Let us first get the processId with the help of show command. ... Read More

Update MySQL date and increment by one Year?

Chandu yadav

Chandu yadav

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

1K+ Views

You can use in-built function date_add() from MySQL. The syntax is as follows −UPDATE yourTableName SET yourDateColumnName=DATE_ADD(yourDateColumnName, interval 1 year);To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table UpdateDate -> ( ... Read More

MySQL date format to convert dd.mm.yy to YYYY-MM-DD?

Chandu yadav

Chandu yadav

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

21K+ Views

Use STR_TO_DATE() method from MySQL to convert. The syntax is as follows wherein we are using format specifiers. The format specifiers begin with %.SELECT STR_TO_DATE(yourDateColumnName, '%d.%m.%Y') as anyVariableName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows.mysql> create table ... Read More

Truncate with condition in MySQL?

Chandu yadav

Chandu yadav

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

2K+ Views

In MySQL, there is no way to truncate with condition. You cannot use truncate statement with where clause.If you want the condition, use delete command −DELETE FROM yourTableName WHERE youCondition;The above syntax is fine but if you want a faster solution, then DELETE is not good in comparison to Truncate. ... Read More

Can an Android Toast be longer than Toast.LENGTH_LONG?

Chandu yadav

Chandu yadav

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

244 Views

Sometimes we need to display more time then LENGTH_LONG. This example demonstrates how to show toast longer than Toast.LENGTH_LONG.Step 1 - Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 - Add the following code ... Read More

MySQL create user if it does not exist?

Chandu yadav

Chandu yadav

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

1K+ Views

You can create user if it does not exist with the help of “create user” command. The command will work on MySQL version 5.7.6 and above. The syntax is as follows −mysql> CREATE USER IF NOT EXISTS 'yourUserName'@'localhost' IDENTIFIED BY 'yourPassword';Apply the above syntax to create a user if it ... Read More

How to find MySQL my.cnf on my windows computer?

Chandu yadav

Chandu yadav

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

2K+ Views

To find my.cnf on Windows system, first open the command prompt with the help of shortcut key Windows + R (run). The snapshot is as follows −Type “services.msc” on command prompt and press ENTER as shown in the following screenshot −Now, a new wizard will open. The snapshot is as ... Read More

Do underscores in a MySQL table name cause issues?

Chandu yadav

Chandu yadav

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

897 Views

No, you won’t get any issues with underscores in a MySQL table name. You will get the issues with a dash in a MySQL table name.Here is the demo that does not have any issue with underscore with table names −_StudentTrackerDemoLet us see the same while creating a table. The ... Read More

How to round down to nearest integer in MySQL?

Chandu yadav

Chandu yadav

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

492 Views

To round down to nearest integer, use FLOOR() function from MySQL. The syntax is as follows −SELECT FLOOR(yourColumnName) from yourTableName;Let us first create a table −mysql> create table FloorDemo -> ( -> Price float -> ); Query OK, 0 rows affected ... Read More

Advertisements