- 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
103 Views
To split a numerical query result, you can use the CONCAT() function in MySQL. Let us first create a table −mysql> create table DemoTable ( StudentId int ); Query OK, 0 rows affected (0.68 sec)Now you can insert some records in the table using insert command −mysql> insert into DemoTable values(2222); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(5555); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(4567); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(8905); Query OK, 1 row affected (0.15 sec)Display all records from ... Read More
245 Views
No, name is not a reserved word in MySQL, you can use without backtick symbol. If you are working on a reserved word then use backtick symbol. Let us first create a table −mysql> create table name ( name varchar(10) ); Query OK, 0 rows affected (0.78 sec)Now you can insert some records in the table using insert command −mysql> insert into name values('John'); Query OK, 1 row affected (0.13 sec) mysql> insert into name values('Carol'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from name;Output+-------+ | name ... Read More
149 Views
For this, use the ORDER BY clause. Let us first create a table −mysql> create table DemoTable ( StudentId int ); Query OK, 0 rows affected (0.59 sec)Now you can insert some records in the table using insert command −mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(70); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values(55); Query OK, 1 row affected ... Read More
5K+ Views
For this, use STR_TO_DATE(). Following is the syntax −insert into yourTableName values(STR_TO_DATE(yourDateValue, yourFormatSpecifier));Let us first create a table −mysql> create table DemoTable ( ShippingDate date ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command : Here, we are inserting formatted dates using date formats like m, d, y, etc −mysql> insert into DemoTable values(STR_TO_DATE('06-01-2019', '%m-%d-%Y')); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(STR_TO_DATE('01-31-2019', '%m-%d-%Y')); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(STR_TO_DATE('02-01-2018', '%m-%d-%Y')); Query OK, 1 row affected (0.27 sec)Display all records ... Read More
233 Views
To get the day name from timestamp, use dayname() function −select dayname(yourColumnName) from yourTableName; Let us first create a table : mysql> create table DemoTable ( LoginDate timestamp ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-06-01'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('2019-06-02'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('2019-06-03'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('2019-06-04'); Query OK, 1 row affected (0.11 sec) mysql> insert into ... Read More
6K+ Views
To get the date between dates, you need to use. Here, we are getting the dates between today and today-7 days −select *from yourTableName where DATE(yourColumnName) > (NOW() - INTERVAL 7 DAY);Note : Let’s say the current date is '2019-06-02’ Let us first create a table.mysql> create table DemoTable ( LoginDate date ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2018-03-21'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('2019-05-22'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('2019-05-27'); ... Read More
595 Views
You can use count(1). Let us first see the syntax −select count(1) from yourTableName;Let us first create a table −mysql> create table DemoTable ( StudentName varchar(100) ); Query OK, 0 rows affected (0.84 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentName) values('John Smith'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable(StudentName) values('Chris Brown'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(StudentName) values('David Miller'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(StudentName) values('Carol Taylor'); Query OK, 1 row affected (0.15 sec)Display all records from ... Read More
115 Views
For this, use the CHAR_LENGTH() function in MySQL. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Subject longtext ); Query OK, 0 rows affected (1.17 sec)Now you can insert some records in the table using insert command −mysql> insert into DemoTable(Subject) values('MySQL, MongoDB'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Subject) values('MySQL, MongoDB'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Subject) values('MongoDB'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(Subject) values('MySQL'); Query OK, 1 row affected (0.15 sec) Display all records from the table using select statement : mysql> select *from DemoTable;Output+----+---------------+ | Id | Subject | +----+---------------+ | 1 | MySQL, MongoDB | | 2 | MySQL, MongoDB | | ... Read More
144 Views
We will create a stored procedure that does not change the variable value whenever the value is updated.Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value int ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value) values(100); Query OK, 1 row affected (0.13 sec) Display all records from the table using select statement : mysql> select *from DemoTable;Output+----+-------+ | Id | Value | +----+-------+ | 1 | 100 | +----+-------+ 1 row ... Read More
109 Views
To perform SELECT with COUNT, use aggregate function COUNT(). Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(100), Subject varchar(100) ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name, Subject) values('John', 'MySQL'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Name, Subject) values('John', 'Java'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Name, Subject) values('Carol', 'MongoDB'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Name, Subject) values('Carol', ... Read More