Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10740 Articles
AmitDiwan
1K+ Views
Let us first create a table −mysql> create table DemoTable1574 -> ( -> StudentCode varchar(20) -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1574 values('111_Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... Read More
AmitDiwan
374 Views
To retrieve table names from a database in MySQL, the syntax is as follows −show tables from yourDatabaseName;Let us implement the above query in order to retrieve table names from a database in MySQL −mysql> show tables from hb_student_tracker;This will produce the following output −+------------------------------+ | Tables_in_hb_student_tracker | +------------------------------+ | ... Read More
AmitDiwan
191 Views
Let us first create a table −mysql> create table DemoTable1572 -> ( -> StudentId int, -> StudentMarks int, -> StudentName varchar(20) -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1572 values(1, 79, 'Sam'); ... Read More
AmitDiwan
1K+ Views
To insert an IF statement into a MySQL query, use the below syntax::select yourColumnName ,if(yourCondition, yourStatement1, yourStatement2) from yourTableName;Let us first create a table −mysql> create table DemoTable1571 -> ( -> Id int, -> Value int -> ); Query OK, 0 rows affected (5.63 sec)Insert some ... Read More
AmitDiwan
304 Views
Let us first create a table −mysql> create table DemoTable1570 -> ( -> ArrivalTime datetime -> ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1570 values('2019-10-15 5:10:00'); Query OK, 1 row affected (0.25 sec) mysql> insert ... Read More
AmitDiwan
3K+ Views
Let us first create a table −mysql> create table DemoTable1569 -> ( -> StudentId varchar(10), -> StudentName varchar(20) -> ); Query OK, 0 rows affected (3.05 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1569 values('John_12', 'John Smith'); Query OK, 1 row ... Read More
AmitDiwan
391 Views
To fetch total number of table rows across databases, use aggregate function SUM() along with INFORMATION SCHEMA. Let us first create a table, which is in “web” database −mysql> create table DemoTable1568 -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.61 sec)Insert some ... Read More
AmitDiwan
666 Views
To get the last 30 rows in MySQL, you need to use ORDER BY DESC and then LIMIT 30. The syntax is as follows −select * from yourTableName order by yourColumnName DESC LIMIT 30;Let us first create a table −mysql> create table DemoTable1567 -> ( -> Id int ... Read More
AmitDiwan
270 Views
For this, you can use CASE WHEN statement. Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris'); Query OK, ... Read More
AmitDiwan
119 Views
For this, use INET_ATON() in MySQL. Let’s say our records are in the form of an IP Address. The INET_ATON() method would allow a user to convert IP Address records to the number and then we can use ORDER BY to order them.Let us first create a table −mysql> create ... Read More