AmitDiwan has Published 10744 Articles

Can we set a single value in MySQL SELECT IN()?

AmitDiwan

AmitDiwan

Updated on 18-Dec-2019 05:42:06

320 Views

Yes, we can set a single value with IN() in MySQL. Let us first create a table−mysql> create table DemoTable    -> (    -> FirstName varchar(20)    -> ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris'); ... Read More

Can we alter order of columns in MySQL?

AmitDiwan

AmitDiwan

Updated on 18-Dec-2019 05:38:19

292 Views

Yes, we can change the order of columns. This can be done using ALTER command and AFTER to set the new order of an individual column. Let us first create a table −mysql> create table DemoTable    -> (    -> `Student_Key_Age` int,    -> `Student_Key_Name` varchar(20),    -> `Student_Key_CountryName` ... Read More

Display records with conditions set using if statement in UPDATE statement with MySQL

AmitDiwan

AmitDiwan

Updated on 18-Dec-2019 05:33:21

144 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20),    -> StudentMarks int,    -> Status varchar(20)    -> ); Query OK, 0 rows affected (0.97 sec)Insert some records in the table using ... Read More

Perform custom sorting in MySQL

AmitDiwan

AmitDiwan

Updated on 18-Dec-2019 05:30:16

355 Views

To perform custom sorting in MySQL, use ORDER BY FIELD(). Let us first create a table −mysql> create table DemoTable    -> (    -> Id int    -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command:mysql> insert into DemoTable values(101); Query ... Read More

Concatenate the column values with separate text in MySQL and display in a single column

AmitDiwan

AmitDiwan

Updated on 18-Dec-2019 05:26:48

378 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.93 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(101, 'Chris'); Query OK, 1 row affected ... Read More

Update MySQL column based on email address?

AmitDiwan

AmitDiwan

Updated on 18-Dec-2019 05:24:17

2K+ Views

Let us first create a table −mysql> create table DemoTable    -> (    -> EmailAddress varchar(20),    -> Score int    -> ); Query OK, 0 rows affected (1.05 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris@gmail.com', 67); Query OK, 1 row affected ... Read More

MySQL query to remove trailing spaces

AmitDiwan

AmitDiwan

Updated on 18-Dec-2019 05:22:21

243 Views

To remove trailing space, use RTRIM() in MySQL. Let us first create a table −mysql> create table DemoTable    -> (    -> FirstName varchar(50)    -> ); Query OK, 0 rows affected (1.38 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John '); Query ... Read More

Delete only some rows from a table based on a condition in MySQL

AmitDiwan

AmitDiwan

Updated on 18-Dec-2019 05:20:41

463 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command:Insert some records in the table using insert command: mysql> insert into ... Read More

How to update MySQL table storage engine

AmitDiwan

AmitDiwan

Updated on 18-Dec-2019 05:12:31

270 Views

To update MySQL table engine, following the below syntax −Syntaxalter table yourTableName ENGINE=InnoDB;Let us first create a table −mysql> create table DemoTable    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20),    -> StudentAge int,    -> StudentCountryName varchar(20)    -> )ENGINE=MyISAM, AUTO_INCREMENT=101; ... Read More

Fetch maximum individual marks for a student with marks1 and marks2 records in MySQL?

AmitDiwan

AmitDiwan

Updated on 18-Dec-2019 05:05:52

283 Views

For this, use MAX() along with GROUP BY clause. Let us first create a table −mysql> create table DemoTable    -> (    -> StudentEmailId varchar(20),    -> Marks1 int,    -> Marks2 int -> ); Query OK, 0 rows affected (0.90 sec)Insert some records in the table using insert ... Read More

Advertisements