- 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)
88 Views
Do not use backticks, you can use single quotes in CONCAT(). Following is the syntax −select concat(yourColumnName1, ' ', yourColumnName2) from yourTableName;Let us first create a table −mysql> create table DemoTable1359 -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1359 values(101, 'Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1359 values(102, 'Adam'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1359 values(103, 'Mike'); Query OK, 1 row ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
694 Views
Use GROUP BY and DATE() for this. Let us first create a table −mysql> create table DemoTable1358 -> ( -> PurchaseDate datetime, -> ProductPrice int -> ); Query OK, 0 rows affected (1.59 sec)Insert some records in the table using insert command. Here, we have inserted date records, with some records with similar dates −mysql> insert into DemoTable1358 values('2019-09-20 12:34:00', 450); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1358 values('2019-09-21 11:00:00', 1050); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable1358 values('2018-09-21 02:10:00', 2050); Query OK, 1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
274 Views
Let us first create a table −mysql> create table DemoTable1357 -> ( -> StudentName varchar(40), -> StudentCountryName varchar(30) -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1357 values('Chris', 'US'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1357 values('David', NULL); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1357 values('David', 'AUS'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1357 values('Carol', NULL); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1357 values('Mike', ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
409 Views
To alter, use the ALTER command with CHANGE as in the below syntax −alter table yourTableName change yourColumnName yourColumnName datatype NULL DEFAULT NULL;Let us first create a table −mysql> create table DemoTable1356 -> ( -> FirstName varchar(30) -> ); Query OK, 0 rows affected (0.56 sec)Let us implement the above syntax to alter a table column to NULL −mysql> alter table DemoTable1356 change FirstName FirstName varchar(30) NULL DEFAULT NULL; Query OK, 0 rows affected (0.17 sec) Records: 0 Duplicates: 0 Warnings: 0Insert some records in the table using insert command −mysql> insert into DemoTable1356 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
859 Views
For this, use GROUP_CONCAT(). Let us first create a table−mysql> create table DemoTable1355 -> ( -> Location text -> ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1355 values('E:'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1355 values('AllPrograms'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1355 values('ChatApplicationInJava'); Query OK, 1 row affected (0.38 sec) mysql> insert into DemoTable1355 values('MainFolder'); Query OK, 1 row affected (0.23 sec)Display 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)
2K+ Views
You may get tis value, if you are missing the value for auto_increment column. The error is as follows −mysql> insert into DemoTable1353 values('Chris', 23); ERROR 1136 (21S01): Column count doesn't match value count at row 1You need to provide the value for auto_increment or leave it to automatic generation.Let us see an example and create a table −mysql> create table DemoTable1353 -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(20), -> Age int, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.52 sec)Insert ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
122 Views
For this, at first, use CAST(). Let us first create a table −mysql> create table DemoTable1352 -> ( -> Value1 int, -> Value2 int -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command−mysql> insert into DemoTable1352 values(10, 30); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable1352 values(40, 60); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1352 values(110, 130); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement−mysql> select * from DemoTable1352; This ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
60 Views
Use HAVING COUNT() for this. Let us first create a table −mysql> create table DemoTable1351 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(40) -> ); Query OK, 0 rows affected (1.08 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1351(StudentName) values('Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1351(StudentName) values('Bob'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1351(StudentName) values('Bob'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1351(StudentName) values('David'); Query OK, 1 row affected (0.11 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
110 Views
To find specific column names, use information_schema.columns Here, I am using Id in place of columnA and Name in place of columnB −mysql> select table_name as TableNameFromWebDatabase -> from information_schema.columns -> where column_name IN ('Id', 'Name') -> group by table_name -> having count(*) = 3;This will produce the following output. Following are the table with columns Id and Name −+--------------------------+ | TableNameFromWebDatabase | +--------------------------+ | student | | distinctdemo | | secondtable | | groupconcatenatedemo ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
61 Views
You can avoid with the help of providing the value (NULL, 0, DEFAULT) with AUTO_INCREMENT. Let us first create a table −mysql> create table DemoTable1350 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.44 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1350 values(NULL, 'Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1350 values(0, 'Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1350 values(DEFAULT, 'Chris'); Query OK, 1 row affected (0.10 sec)Display all records ... Read More