
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 10744 Articles

AmitDiwan
588 Views
Let us first create a table −mysql> create table DemoTable ( StudentId int, StudentMarks int ); Query OK, 0 rows affected (0.83 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1000, 78); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable ... Read More

AmitDiwan
233 Views
To assign value 1 while altering, use the MySQL DEFAULT. This will itself enter 1 if nothing is inserted in the same column while using the INSERT command.Let us first create a table −mysql> create table DemoTable ( isAdult int ); Query OK, 0 rows affected (1.39 sec)Following is ... Read More

AmitDiwan
399 Views
To find the minimum and maximum values in a single query, use MySQL UNION. Let us first create a table −mysql> create table DemoTable ( Price int ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(88); Query ... Read More

AmitDiwan
280 Views
For this, use the FOUND_ROWS in MySQL. Following is the syntax −SELECT SQL_CALC_FOUND_ROWS TABLE_NAME FROM `information_schema`.tables WHERE TABLE_NAME LIKE "yourValue%" LIMIT yourLimitValue;Here, I am using the database ‘web’ and I have lots of tables, let’s say which begins from DemoTable29. Let us implement the above syntax to fetch only 4 ... Read More

AmitDiwan
2K+ Views
To get only the date from DateTime, use the date format specifiers −%d for day %m for month %Y for yearLet us first create a table −mysql> create table DemoTable ( AdmissionDate datetime ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command ... Read More

AmitDiwan
10K+ Views
To replace, use the REPLACE() MySQL function. Since you need to update the table for this, use the UPDATE() function with the SET clause.Following is the syntax −update yourTableName set yourColumnName=replace(yourColumnName, yourOldValue, yourNewValue);Let us first create a table −mysql> create table DemoTable ( FirstName varchar(100), CountryName varchar(100) ); ... Read More

AmitDiwan
180 Views
For this, you can use the ORDER BY CASE statement. Let us first create a table −mysql> create table DemoTable ( StudentName varchar(100), StudentMarks int ); Query OK, 0 rows affected (0.97 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 45); Query ... Read More

AmitDiwan
246 Views
To order by the first number in a set of numbers, use ORDER BY SUBSTRING_INDEX(). Let us first create a table −mysql> create table DemoTable ( SetOfNumbers text ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('245, ... Read More

AmitDiwan
688 Views
Yes, but you need to add a backtick symbol to the reserved word (index) to avoid error while using it as a column name.Let us first create a table −mysql> create table DemoTable ( `index` int ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table ... Read More

AmitDiwan
103 Views
Let us first create a table −mysql> create table DemoTable ( FirstName varchar(100), Score int ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('David', 59); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable ... Read More