- 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
849 Views
Here is the query to create first table.mysql> create table DemoTable1 -> ( -> StudentName varchar(20), -> StudentMarks int -> ); Query OK, 0 rows affected (0.67 sec)To understand the above concept, let us create second table.mysql> create table DemoTable2 -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable2 values('Chris'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select * from DemoTable2;This will produce the following output −+-------+ ... Read More
1K+ Views
Use IS NOT NULL to find the non-null values and display them. Let us first create a table −mysql> create table DemoTable1458 -> ( -> StudentName varchar(20), -> StudentScore int -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1458 values('Chris Brown', 56); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1458 values('David Miller', NULL); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1458 values('John Doe', 78); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1458 values('Adam Smith', NULL); ... Read More
637 Views
To convert timestamp to month, use the FROM_UNIXTIME() method as in the below syntax −select month(from_unixtime(yourColumnName)) from yourTableName;Let us first create a table −mysql> create table DemoTable1457 -> ( -> Value bigint -> ); Query OK, 0 rows affected (0.85 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1457 values(1570207117); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable1457 values(1548947534); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1457 values(1575213134); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select * from ... Read More
385 Views
To perform MySQL search between two dates, use BETWEEN keyword. Let us first create a table −mysql> create table DemoTable1456 -> ( -> CustomerName varchar(30), -> StartOfferDate date, -> EndOfferDate date -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1456 values('Chris', '2019-09-01', '2019-09-30'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1456 values('David', '2019-09-01', '2019-10-30'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1456 values('Bob', '2018-10-01', '2018-10-20'); Query OK, 1 row affected (0.15 sec)Display all records from the table ... Read More
61 Views
To check for NULL values in SELECT, use MySQL NULL. Let us first create a table −mysql> create table DemoTable1455 -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1455 values('John'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable1455 values(NULL); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1455 values(''); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement −mysql> select * from DemoTable1455;This will produce the following output −+------+ ... Read More
94 Views
Following is the syntax −select * from yourTableName order by ( yourColumnName> now()) desc, (case when yourColumnName > now() then yourColumnName end) , yourColumnName desc limit 1;Let us first create a table −mysql> create table DemoTable1454 -> ( -> ShippingDate date -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1454 values('2019-10-01'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable1454 values('2019-10-03'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable1454 values('2019-10-05'); Query OK, 1 row affected (0.25 sec) mysql> insert ... Read More
144 Views
To print, the syntax is as follows −mysql -uroot -t -e "your Select Query " -pTo implement the above syntax, let us open the command prompt −Now, reach the MySQL bin −Let us implement the above syntax to easily print structured SQL select. Following is the query −This will produce the following output −
145 Views
Let us first create a table −mysql> create table DemoTable1453 -> ( -> CustomerId int, -> CustomerReviewNumber int -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1453 values(10, 4); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1453 values(10, 4); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1453 values(11, 5); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1453 values(11, 5); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable1453 values(11, 5); Query OK, 1 ... Read More
603 Views
Let us first create a table −mysql> create table DemoTable1452 -> ( -> FavouriteColor varchar(50) -> ); Query OK, 0 rows affected (2.42 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1452 values('Red'); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable1452 values('Yellow'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1452 values('Yellow'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1452 values('Yellow'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable1452 values('Blue'); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable1452 values('Blue'); ... Read More
174 Views
Let us first create a table −mysql> create table DemoTable1451 -> ( -> JoiningDate date -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1451 values('2019-07-21'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable1451 values('2018-01-31'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1451 values('2017-06-01'); Query OK, 1 row affected (0.20 sec)Display all records from the table using select statement −mysql> select * from DemoTable1451;This will produce the following output −+-------------+ | JoiningDate | +-------------+ | 2019-07-21 | | 2018-01-31 | ... Read More