- 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
266 Views
Let us first create a table −mysql> create table DemoTable828( CustomerName varchar(100), InterestRate varchar(100) ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable828 values('Chris', '10%'); Query OK, 1 row affected (0.60 sec) mysql> insert into DemoTable828 values('Robert', '11.5%'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable828 values('David', '15.90%'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable828 values('Bob', '20%'); Query OK, 1 row affected (0.16 sec)Display all records from the table using select statement −mysql> select *from DemoTable828;This will produce the following ... Read More
281 Views
Let us first create a table −mysql> create table DemoTable855(DueDate timestamp); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable855 values('2019-08-07'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable855 values('0000-00-00'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable855 values('2019-07-06'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable855 values('2016-04-10'); Query OK, 1 row affected (0.16 sec)Display all records from the table using select statement −mysql> select *from DemoTable855;This will produce the following output −+----------------------+ | DueDate ... Read More
208 Views
To replace backslashes with any other special character, use the REPLACE() method. Let us first create a table −mysql> create table DemoTable827(Path text); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable827 values('C\MySQL'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable827 values('D\NewFolder\'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable827 values('E:\myFolder\MyDocument'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select *from DemoTable827;This will produce the following output −+------------------------+ | Path ... Read More
1K+ Views
Let us first create a table −mysql> create table DemoTable(Value int); Query OK, 0 rows affected (1.79 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(50); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.68 sec) mysql> insert into DemoTable values(30); 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 −+-------+ | Value | +-------+ | 50 | | 20 | | 30 | +-------+ 3 rows in ... Read More
165 Views
For this, use the TRIM() function. Let us first create a table −mysql> create table DemoTable826( FirstName varchar(100), Age int ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using the insert command. Here, we have set the FirstName as whitespace for some of the records −mysql> insert into DemoTable826 values(' ', 24); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable826 values(' ', 22); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable826 values('Chris', 26); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable826 values('Robert', 27); Query ... Read More
757 Views
Use the OPTIMIZE TABLE command to optimize a MySQL table −optimize table yourTableName;Let us first create a table −mysql> create table DemoTable( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(100) ); Query OK, 0 rows affected (1.38 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('Chris'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable(Name) values('Robert'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Name) values('Bob'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable(Name) values('David'); Query OK, 1 row affected (0.38 sec)Display all records from ... Read More
200 Views
Let us first create a table −mysql> create table DemoTable(Name varchar(100)); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Sam'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Robert'); Query OK, 1 row affected (0.37 sec) mysql> insert into DemoTable values('Mike'); Query OK, 1 row affected (0.09 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+--------+ | Name | +--------+ | Chris | ... Read More
213 Views
To sum, you can use aggregate function SUM(). Let us first create a table −mysql> create table DemoTable850( Id int, Price int ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable850 values(1, 90); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable850 values(2, 100); Query OK, 1 row affected (0.55 sec) mysql> insert into DemoTable850 values(2, 50); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable850 values(1, 80); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable850 values(1, 60); Query OK, ... Read More
110 Views
To update the last entry of a particular ID in MySQL, use ORDER BY DESC LIMIT 1. This would allow you to update the last entry i.e. row records.Let us first create a table −mysql> create table DemoTable824( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(100), ClientAge int ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable824(ClientName, ClientAge) values('Chris', 23); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable824(ClientName, ClientAge) values('Robert', 26); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable824(ClientName, ... Read More
307 Views
To order by specific field value first in MySQL, use ORDER BY FIELD(). Let us first create a table −mysql> create table DemoTable849(Color varchar(100)); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable849 values('RED'); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable849 values('ORANGE'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable849 values('BLUE'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable849 values('GREEN'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable849;This will ... Read More