AmitDiwan has Published 10744 Articles

Group concatenate the last name from a MySQL column and set a condition to display limited records

AmitDiwan

AmitDiwan

Updated on 03-Sep-2019 11:04:18

87 Views

Use GROUP_CONCAT() to perform group concatenation and set a condition. Let us first create a table −mysql> create table DemoTable813(    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserFirstName varchar(100),    UserLastName varchar(100) ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command ... Read More

How to use MySQL LIKE to create a search system and display results on the basis of keyword?

AmitDiwan

AmitDiwan

Updated on 03-Sep-2019 11:01:26

150 Views

To display results on the basis of keyword, use the LIKE operator as in the following syntax −select *from yourTableName where yourColumnName LIKE '%yourValue%';Let us first create a table −mysql> create table DemoTable812(Comments text); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> ... Read More

Is INNODB enabled by default in MySQL?

AmitDiwan

AmitDiwan

Updated on 03-Sep-2019 11:00:23

167 Views

Yes, it is enabled by default from MySQL version 4.0. Here, we are using MySQL version 8.0.1 −mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.12    | +-----------+ 1 row in set (0.00 sec)Let us now check the my.ini wherein the default engine type InnoDB is visible ... Read More

Can I insert two or more rows in a MySQL table at once?

AmitDiwan

AmitDiwan

Updated on 03-Sep-2019 10:57:22

118 Views

Yes, we can insert two or more rows in a table at once. Following is the syntax −insert into yourTableName(yourColumnName1, yourColumnName2) values(yourValue1, yourValue2), (yourValue1, yourValue2), .........N;Let us first create a table −mysql> create table DemoTable811(    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(100),    StudentAge int ); ... Read More

MySQL query to count rows with a specific column?

AmitDiwan

AmitDiwan

Updated on 03-Sep-2019 10:55:38

258 Views

Let us first create a table −mysql> create table DemoTable841(    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Value varchar(100) ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable841(Value) values('X'); Query OK, 1 row affected (0.19 sec) mysql> ... Read More

Implement MySQL IN for 2 columns to display only selected records

AmitDiwan

AmitDiwan

Updated on 03-Sep-2019 10:53:53

94 Views

Let us first create a table −mysql> create table DemoTable810(    First int,    Second int ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable810 values(20, 40); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable810 values(70, ... Read More

MySQL SELECT to sum a column value with previous value

AmitDiwan

AmitDiwan

Updated on 03-Sep-2019 10:51:46

859 Views

For this, you can use a session variable. Let us first create a table −mysql> create table DemoTable809(Price int); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable809 values(40); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable809 ... Read More

Implement specific record ordering with MySQL

AmitDiwan

AmitDiwan

Updated on 03-Sep-2019 10:48:49

114 Views

To set specific record ordering, use ORDER BY LIKE. Let us first create a table−mysql> create table DemoTable808(Value varchar(100)); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable808 values('smith'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable808 ... Read More

Check if a value exists in a column in a MySQL table?

AmitDiwan

AmitDiwan

Updated on 03-Sep-2019 10:46:28

3K+ Views

Let us first create a table −mysql> create table DemoTable807(    ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientName varchar(100),    ClientCountryName varchar(100) ); Query OK, 0 rows affected (0.64 sec) Insert some records in the table using insert command −mysql> insert into DemoTable807(ClientName, ClientCountryName) values('Chris', 'UK'); Query ... Read More

Is there a way to select a value which matches partially in MySQL?

AmitDiwan

AmitDiwan

Updated on 03-Sep-2019 10:42:31

215 Views

To match partially, use LIKE operator. Let us first create a table −mysql> create table DemoTable806(    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(100),    StudentSubject varchar(100) ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable806(StudentName, ... Read More

Advertisements