- 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
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
1K+ Views
To sum columns across multiple tables, use UNION ALL. To understand the concept, let us create first table. The query to create first table is as followsmysql> create table Products1 -> ( -> ProductId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ProductName varchar(20), -> ProductPrice int -> ); Query OK, 0 rows affected (0.50 sec)Insert some records in the first table using insert command. The query is as follows −mysql> insert into Products1(ProductName, ProductPrice) values('Product-1', 100); Query OK, 1 row affected (0.22 sec) mysql> insert into Products1(ProductName, ProductPrice) values('Product-2', 200); Query OK, 1 row affected ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
86 Views
To achieve this, you need to set sql_log_bin to 0. To understand the concept, let us create a table. The query to create a table is as followsmysql> create table SQLStatementsDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20) -> ); Query OK, 0 rows affected (0.79 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into SQLStatementsDemo(UserName) values('John'); Query OK, 1 row affected (0.18 sec) mysql> insert into SQLStatementsDemo(UserName) values('Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into SQLStatementsDemo(UserName) values('Bob'); Query ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
1K+ Views
Yes, deleting row from view delete row from base table. Let us understand this by creating a new table. The query to create a table is as followsmysql> create table deleteFromBaseTableDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.83 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into deleteFromBaseTableDemo(Name) values('John'); Query OK, 1 row affected (0.18 sec) mysql> insert into deleteFromBaseTableDemo(Name) values('Carol'); Query OK, 1 row affected ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
420 Views
To get distinct values and count them, you can use GROUP BY clause.The syntax is as followsselect yourColumnName, count(*) as anyAliasName from yourTableName group by yourColumnName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table GroupByAndCountDemo -> ( -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(100) -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into GroupByAndCountDemo(ClientName) values('John'); Query OK, 1 row affected (0.18 sec) mysql> insert ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
438 Views
To understand the concept, let us first create a table. The query to create a table is as followsmysql> create table ReorderSortDemo -> ( -> UserId int -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into ReorderSortDemo values(14); Query OK, 1 row affected (0.13 sec) mysql> insert into ReorderSortDemo values(4); Query OK, 1 row affected (0.10 sec) mysql> insert into ReorderSortDemo values(6); Query OK, 1 row affected (0.11 sec) mysql> insert into ReorderSortDemo values(3); Query ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
2K+ Views
You can use COALESCE() function for this. In the COALESCE() function, it returns the first NON NULL value from the column. To understand the concept, let us first create a demo tablemysql> create table combineTwoColumnsDemo -> ( -> UserId int, -> UserName varchar(20), -> UserAge int -> ); Query OK, 0 rows affected (1.12 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into combineTwoColumnsDemo values(101, 'John', 23); Query OK, 1 row affected (0.16 sec) mysql> insert into combineTwoColumnsDemo values(102, 'Carol', 20); Query OK, 1 row affected (0.14 ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
663 Views
You can use aggregate function SUM() along with IF to determine if a value appears in a GROUP BY group.Let us first create a demo tablemysql> create table GroupbygroupDemo -> ( -> UserId int, -> UserName varchar(20) -> ); Query OK, 0 rows affected (1.48 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into GroupbygroupDemo values(10, 'John'); Query OK, 1 row affected (0.14 sec) mysql> insert into GroupbygroupDemo values(10, 'Carol'); Query OK, 1 row affected (0.08 sec) mysql> insert into ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
462 Views
You can stop rounding decimal field with the help of DECIMAL() function. Here is the demo of a rounded decimal field. For our example, let us first create a demo tablemysql> create table stopRoundingDemo -> ( -> Amount DECIMAL(7) -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into stopRoundingDemo values(7836.783); Query OK, 1 row affected, 1 warning (0.43 sec) mysql> insert into stopRoundingDemo values(1737.67); Query OK, 1 row affected, 1 warning (0.23 sec) mysql> insert into stopRoundingDemo values(110.50); Query OK, 1 ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
959 Views
You can use CONCAT() function to set date and time fields to get DATETIME field.Let us create a demo tablemysql> create table getDateTimeFieldsDemo -> ( -> ShippingDate date, -> ShippingTime time, -> Shippingdatetime datetime -> ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into getDateTimeFieldsDemo(ShippingDate, ShippingTime) values('2018-01-21', '09:45:34'); Query OK, 1 row affected (0.16 sec) mysql> insert into getDateTimeFieldsDemo(ShippingDate, ShippingTime) values('2013-07-26', '13:21:20'); Query OK, 1 row affected (0.13 sec) mysql> ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
1K+ Views
To add/ concatenate text values within a select clause, you can use concat() function.Let us create a tablemysql> create table ConcatenatingDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20), -> UserCountryName varchar(20) -> ); Query OK, 0 rows affected (0.82 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into ConcatenatingDemo(UserName, UserCountryName) values('John', 'US'); Query OK, 1 row affected (0.14 sec) mysql> insert into ConcatenatingDemo(UserName, UserCountryName) values('Carol', 'UK'); Query OK, ... Read More