AmitDiwan has Published 10740 Articles

How to escape '%' character on the left and middle part of strings in a MySQL column?

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:48:55

164 Views

Let us first create a table −mysql> create table DemoTable629 (StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentSubject text); Query OK, 0 rows affected (0.77 sec)Insert some records in the table using insert command −mysql> insert into DemoTable629(StudentSubject) values('MySQL%'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable629(StudentSubject) ... Read More

MySQL to get only the floating-point numbers from a list of values in a column

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:38:43

528 Views

Let us first create a table −mysql> create table DemoTable628 (Value DECIMAL(10, 2)); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable628 values(10.97); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable628 values(20.04); Query OK, 1 row affected ... Read More

Convert the case of every value in a MySQL Column to uppercase

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:32:02

397 Views

For this, use UPPER() on MySQL column. Let us first create a table −mysql> create table DemoTable627 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100)); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable627(FirstName) values(UPPER('John')); Query OK, 1 row ... Read More

Pad the values of the column with zeros in MySQL

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:29:31

166 Views

For this, use the concept of ZEROFILL. It pads the displayed value of the field with zeros up to the display width set in the column definitionLet us first create a table −mysql> create table DemoTable626 (Value int(5) zerofill); Query OK, 0 rows affected (0.71 sec)Insert some records in the ... Read More

Selecting and displaying only some rows from a column in a MySQL table

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:25:10

321 Views

Let us first create a table −mysql> create table DemoTable625 (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100), StudentScore int ); Query OK, 0 rows affected (1.01 sec)Insert some records in the table using insert command −mysql> insert into DemoTable625(StudentFirstName, StudentScore) values('John', 98); Query OK, 1 row ... Read More

Get the time difference between values in different columns with MySQL

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:20:42

796 Views

For this, you can use time_format() and time_diff(). To find the time difference, you need to use the time_diff() method. Let us first create a table −mysql> create table DemoTable624 (PunchIn datetime, PunchOut datetime); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> ... Read More

Select Statement to retrieve the same first names with similar last name (but different case) using MySQL?

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:17:49

440 Views

Let us first create a table −mysql> create table DemoTable623 (FirstName varchar(100), LastName varchar(100), Age int); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable623 values('John', 'Smith', 23); Query OK, 1 row affected (0.66 sec) mysql> insert into DemoTable623 values('Adam', ... Read More

MySQL query to set different combinations for values in a table?

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:15:03

404 Views

Let us first create a table −mysql> create table DemoTable622 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value1 int, Value2 int); Query OK, 0 rows affected (1.08 sec)Insert some records in the table using insert command −mysql> insert into DemoTable622(Value1, Value2) values(1000, 1000); Query OK, 1 row affected (0.23 sec) ... Read More

How to group by column name and ensure the query retrieves the last update in MySQL?

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:12:30

113 Views

Let us first create a table −mysql> create table DemoTable621 (UserName varchar(100), UserEmailId varchar(100), UserLastPost datetime); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable621 values('John', 'John@gmail.com', '2019-04-10 11:01:10'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable621 ... Read More

Where is MySQL bin directory located in Windows OS?

AmitDiwan

AmitDiwan

Updated on 23-Aug-2019 07:00:58

5K+ Views

Let’s say we installed MySQL version is 8.0 on our Windows OS. The bin directory is present at the following location −C:\Program Files\MySQL\MySQL Server 8.0\binLet us check the location. The screenshot is as follows −These are the drives −Go to C: drive and click Program Files −Now, click “MySQL” and ... Read More

Advertisements