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
545 Views
Here, let’s say you have a string with form “StringSeparatorNumber” form like John/56989. Now if you want to remove the number after separator /, then use the SUBSTRING_INDEX(). Let us first create a table −mysql> create table DemoTable ( StudentName varchar(100) ); Query OK, 0 rows affected (1.05 sec)Insert ... Read More
AmitDiwan
432 Views
For thus, use MySQL REPLACE(). Let us first create a table −mysql> create table DemoTable ( FolderLocation text ); Query OK, 0 rows affected (0.80 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('C/ProgramFiles/AllMySQLProgram'); Query OK, 1 row affected (0.13 sec) mysql> insert into ... Read More
AmitDiwan
105 Views
Yes, we can check for a blank string and 0 in a single condition. Let us first create a table −mysql> create table DemoTable ( ClientId varchar(40) ); Query OK, 0 rows affected (1.01 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('CLI-01'); Query ... Read More
AmitDiwan
714 Views
To collapse rows into a comma-delimited list, use GROUP_CONCAT(). Let us first create a table −mysql> create table DemoTable ( Id int, Name varchar(40) ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris Brown'); Query ... Read More
AmitDiwan
1K+ Views
In MySQL, you can achieve sp_help with the help of SHOW CREATE command.CASE 1 −For table, the syntax is as follows −SHOW CREATE TABLE yourTableName;CASE 2 −For stored procedure, the syntax is as follows −SHOW CREATE PROCEDURE yourProcedureName;Let us first create a table −mysql> create table DemoTable ( EmployeeId ... Read More
AmitDiwan
362 Views
For this, you can use SUBSTRING_INDEX(). Let us first create a table −mysql> create table DemoTable ( Words TEXT ); Query OK, 0 rows affected (1.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Learn With Ease'); Query OK, 1 row affected (0.32 sec) ... Read More
AmitDiwan
152 Views
Let us first create a table −mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(40), ClientAge int, ClientCountryName varchar(40) ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ClientName, ClientAge, ClientCountryName) ... Read More
AmitDiwan
2K+ Views
To make a date column null, use ALTER TABLE and MODIFY and set the date to NULL. Following is the syntax −alter table yourTableName modify column yourColumnName date NULL;Let us first create a table. Here, we have set the column as NOT NULL −mysql> create table DemoTable ( ShippingDate ... Read More
AmitDiwan
496 Views
The syntax is as follows to get the column names of a table −select column_name from information_schema.columns where table_schema='yourDatabaseName' and table_name=’yourTableName’;Let us first create a table −mysql> create table DemoTable ( EmployeeId int, EmployeeFirstName varchar(20), EmployeeLastName varchar(20), EmployeeAge int, EmployeeCountryName varchar(40), IsMarried tinyint(1), ... Read More
AmitDiwan
489 Views
To check if field of a table has NOT NULL property, you can use any of the two syntaxes. The first syntax is as follows −desc yourTableName;Following is the second syntax −select column_name, is_nullable from information_schema.columns where table_schema = ‘yourDatabaseName’ and table_name = 'yourTableName’;Let us first ... Read More