- 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
126 Views
To set a filter for type, you can use below syntax −SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'yourDataTypeName';Let us implement the above syntax to show fields only with field type text −mysql> SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE = 'text';This will produce the following output −+---------------------------------------------+--------------------------------+ | TABLE_NAME | COLUMN_NAME | +---------------------------------------------+--------------------------------+ | COLUMNS ... Read More
1K+ Views
To list all rows by group, you can use GROUP_CONCAT(). Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(20), Value varchar(100) ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, Value) values('John', 'John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Name, Value) values('Carol', 'Carol'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(Name, Value) values('John', 'Works'); Query OK, 1 row affected (0.13 sec) mysql> insert ... Read More
210 Views
You can achieve this with the help of CAST() function. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Score int ); Query OK, 0 rows affected (0.72 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Score) values(10); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(Score) values(100); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Score) values(11); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(Score) values(97); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Score) values(78); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(Score) values(89); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+----+-------+ | Id | Score | +----+-------+ | 1 | 10 | ... Read More
463 Views
Use regular expression along with CASE statement. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value varchar(20) ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value) values('101'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Value) values('P'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(Value) values('A'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(Value) values('53'); Query OK, 1 row affected (0.13 sec) mysql> ... Read More
498 Views
To select specific rows, use FIND_IN_SET() function in MySQL. Let us first create a table −mysql> create table DemoTable ( ListOfValues varchar(200) ); Query OK, 0 rows affected (0.31 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('112, 114, 567, Java, 345'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('222, 214, 256'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('2, 567, 98, C'); Query OK, 1 row affected (0.06 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This ... Read More
2K+ Views
To perform filtering by multiple columns, use where clause along with OR. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(10), Score int ); Query OK, 0 rows affected (0.28 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, Score) values('John', 80); Query OK, 1 row affected (0.04 sec) mysql> insert into DemoTable(Name, Score) values('John', 90); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable(Name, Score) values('Carol', 89); Query OK, 1 row affected (0.04 sec) ... Read More
362 Views
To fetch data between two rows, use the concept of LIMIT. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(10) ); Query OK, 0 rows affected (0.22 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('Larry'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable(Name) values('Robert'); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(Name) values('Chris'); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(Name) values('David'); Query OK, 1 row affected ... Read More
274 Views
To avoid repair with keycache in MySQL, you need to follow the below syntax −create table yourNewTableName as (select *from yourOldTableName); alter table yourNewTableName add index(yourCoumnName);Let us first create a table −mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(20), StudentLastName varchar(20) ); Query OK, 0 rows affected (0.24 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentFirstName, StudentLastName) values('John', 'Doe'); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(StudentFirstName, StudentLastName) values('David', 'Miller'); Query OK, 1 row affected (0.05 sec)Display all records from ... Read More
467 Views
Let us first create a table −mysql> create table DemoTable ( ProductId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ProductQuantity int, ProductPrice int ); Query OK, 0 rows affected (0.19 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ProductQuantity, ProductPrice) values(10, 100); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable(ProductQuantity, ProductPrice) values(5, 11); Query OK, 1 row affected (0.04 sec) mysql> insert into DemoTable(ProductQuantity, ProductPrice) values(3, 140); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(ProductQuantity, ProductPrice) values(2, 450); Query OK, 1 row affected ... Read More
53 Views
You can use regular expression for this. Let us first create a table −mysql> create table DemoTable ( ProductId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ProductName varchar(20) ); Query OK, 0 rows affected (0.19 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ProductName) values('Product-1'); Query OK, 1 row affected (0.05 sec) mysql> insert into DemoTable(ProductName) values('Product2'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable(ProductName) values('Product1'); Query OK, 1 row affected (0.04 sec) mysql> insert into DemoTable(ProductName) values('Product-3'); Query OK, 1 row affected (0.05 sec) mysql> ... Read More