- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4378 Articles for MySQL
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
300 Views
If the string begins with integer then it converts the string to integer, otherwise it won’t. Let us first create a −mysql> create table DemoTable1390 -> ( -> StudentId varchar(20) -> ); Query OK, 0 rows affected (0.93 sec)Insert some records in the table using insert −mysql> insert into DemoTable1390 values('563_John'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1390 values('1001_Carol_Taylor'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1390 values('David_Miller_789'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable1390 values('456_AdamSmith'); Query OK, 1 row affected (0.11 sec)Display all records from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Let us first create a −mysql> create table DemoTable1 -> ( -> StudentFirstName varchar(20), -> StudentLastName varchar(20), -> StudentAge int, -> StudentCountryName varchar(20) -> ); Query OK, 0 rows affected (4.20 sec)Let us now make all column names lower case in MySQL −mysql> select concat('alter table ', table_name, ' change `', column_name, '` `', -> lower(column_name), '` ', column_type, ';') -> from information_schema.columns where table_schema = 'demo';This will produce the following output −+-----------------------------------------------------------------------------------------------------------------+ | concat('alter table ', table_name, ' change `', column_name, '` `', lower(column_name), '` ', column_type, ';') | +-----------------------------------------------------------------------------------------------------------------+ | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
108 Views
Let us first create a −mysql> create table DemoTable1620 -> ( -> Subject varchar(20) -> ); Query OK, 0 rows affected (0.42 sec)Insert some records in the table using insert −mysql> insert into DemoTable1620 values('mysql'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1620 values('MySql'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1620 values('mYSQL'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1620 values('MySQL'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable1620 values('MYSQL'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
For this, use the join concept. Let us first create a −mysql> create table DemoTable1389 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentMarks int -> ); Query OK, 0 rows affected (2.73 sec)Insert some records in the table using insert command. Here, we have inserted duplicate values as well −mysql> insert into DemoTable1389(StudentMarks) values(40); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable1389(StudentMarks) values(40); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1389(StudentMarks) values(68); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable1389(StudentMarks) values(78); Query OK, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Following is the syntax −select * from yourViewName;Let us first create a table −mysql> create table DemoTable1388 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(40) -> ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1388(StudentName) values('Chris'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1388(StudentName) values('Bob'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1388(StudentName) values('David'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1388(StudentName) values('Mike'); Query OK, 1 row affected (0.29 sec)Display all ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
4K+ Views
To combine, use GROUP_CONCAT() function to combine some attributes in two rows into one. As a separator, use hyphens.Let us first create a table −mysql> create table DemoTable1386 -> ( -> Title varchar(255), -> Name varchar(60) -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1386 values('Introduction to MySQL', 'Paul DuBois'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1386 values('Java in Depth', 'Khalid Mughal'); Query OK, 1 row affected (0.48 sec) mysql> insert into DemoTable1386 values('Introduction to MySQL', 'Russell Dyer'); Query OK, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
161 Views
To obtain multiple rows in a single MySQL query, use LIKE operator. Let us first create a table −mysql> create table DemoTable1385 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.90 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1385(Name) values('Chris Brown'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1385(Name) values('Adam Smith'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable1385(Name) values('Carol Taylor'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1385(Name) values('John ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
387 Views
Let us first create a table −mysql> create table DemoTable1384 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> StudentAge int -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command. Here, we are inserting multiple rows in a single query −mysql> insert into DemoTable1384(StudentName, StudentAge) values('Chris Brown', 21), ('David Miller', 22), -> ('Carol Taylor', 19), ('Adam Smith', 23); Query OK, 4 rows affected (0.11 sec) Records: 4 Duplicates: 0 Warnings: 0Display all records from the table using select statement −mysql> select * ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
453 Views
For this, use aggregate function MAX(). Let us first create a table −mysql> create table DemoTable1383 -> ( -> Id int, -> PlayerScore int -> ); Query OK, 0 rows affected (0.90 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1383 values(200, 78); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1383 values(200, 89); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1383 values(200, 89); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1383 values(200, 87); Query OK, 1 row affected (0.29 sec) mysql> insert into ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
344 Views
To swap two values in a column, use CASE WHEN statement. Let us first create a table −mysql> create table DemoTable1382 -> ( -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1382 values('John'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1382 values('Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1382 values('Adam'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1382 values('Bob'); Query OK, 1 row affected (0.17 sec)Display all records from the table using ... Read More