- 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 6702 Articles for Database
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
277 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)
410 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)
865 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)
62 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
256 Views
Let us first create a table −mysql> create table DemoTable1349 -> ( -> ProductId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ProductPrice int -> ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1349(ProductPrice) values(7644); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable1349(ProductPrice) values(90843); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable1349(ProductPrice) values(9083); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1349(ProductPrice) values(10000); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
177 Views
Following is the syntax −select * from yourTableName order by yourColumnName=0, yourColumnName;Let us first create a table −mysql> create table DemoTable1348 -> ( -> Amount int -> ); Query OK, 0 rows affected (0.80 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1348 values(100); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1348 values(0); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1348 values(90); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1348 values(45); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1348 values(0); Query ... Read More