Difference Between SHOW INDEX, SHOW INDEXES, and SHOW KEYS in MySQL

AmitDiwan
Updated on 12-Dec-2019 06:21:48

293 Views

There is no difference between show index, show indexes and show keys. They have similar meaning.Let us first create a table −mysql> create table DemoTable1549    -> (    -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> EmployeeName varchar(20)    -> ); Query OK, 0 rows affected (0.82 sec)Following is the query to create an index −mysql> create index name_index1 on DemoTable1549(EmployeeName); Query OK, 0 rows affected (0.41 sec) Records: 0  Duplicates: 0  Warnings: 0Following is the query for SHOW INDEX −mysql> show index from DemoTable1549;This will produce the following output −+---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table         ... Read More

Create ALV in Docking Container in SAP

vanithasree
Updated on 12-Dec-2019 06:19:59

722 Views

Wa_fieldcat is a structure used as a container for the information that has to be added to t_fieldcat.Following Parameters are passed:                                *  pv_field   TYPE any for Field                               *  pv_tabname TYPE any for Table Name               *  pv_coltext TYPE any for Header TextThese variables can’t append under t_fieldcat without putting them in a unified structure.

MySQL Query to Sort by Certain Last String Character

AmitDiwan
Updated on 12-Dec-2019 06:17:47

339 Views

For this, you can use the CASE statement. To sort, use the ORDER BY clause. Let us first create a table −mysql> create table DemoTable    -> (    -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> ClientName varchar(20)    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command. Some records have certain last string like -D, etc −mysql> insert into DemoTable(ClientName) values('Mike'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(ClientName) values('John'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable(ClientName) values('John-D'); Query OK, 1 ... Read More

MySQL Query to Fetch Specific Records from Comma-Separated Values

AmitDiwan
Updated on 12-Dec-2019 06:15:57

905 Views

To fetch records from comma separated values, use MySQL FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable1548    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20),    -> ArrayListOfMarks varchar(100)    -> ); Query OK, 0 rows affected (0.88 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1548(StudentName, ArrayListOfMarks) values('Chris', '56, 78, 90, 87'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable1548(StudentName, ArrayListOfMarks) values('Bob', '90, 78, 65'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1548(StudentName, ArrayListOfMarks) values('David', '91, 34, 56, ... Read More

Fetch Student Records Whose Result Declared 12 Days Before Current Date in MySQL

AmitDiwan
Updated on 12-Dec-2019 06:14:16

210 Views

For this, you need to compare and find the difference between the current date and the result date of students. This can be done with AND operator along with DATEDIFF().Let us first create a table −mysql> create table DemoTable1547    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(20),    -> StudentMarks int,    -> StudentResultDeclareDate datetime    -> ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1547(StudentName, StudentMarks, StudentResultDeclareDate) values('Chris', 56, '2019-10-13 13:00:00')    -> ; Query OK, 1 row affected (0.16 ... Read More

Format Numbers with Spaces in MySQL Query

AmitDiwan
Updated on 12-Dec-2019 06:11:52

283 Views

Let us first create a table −mysql> create table DemoTable1546    -> (    -> Number varchar(20)    -> ); Query OK, 0 rows affected (0.99 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1546 values('145 78 90'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1546 values('89 789 564 903'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1546 values('1345 7894 866 653534'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select * from DemoTable1546;This will produce the following output −+----------------------+ | Number ... Read More

MySQL Procedure to Display a Select Statement Twice

AmitDiwan
Updated on 12-Dec-2019 06:10:55

226 Views

To understand, let us create a stored procedure. Here, we have 2 select statements in the stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE select_statement()    -> BEGIN    ->    SELECT "HI" AS `FIRST VALUE`;    ->    SELECT "HELLO" AS `SECOND VALUE`;    -> END    -> // Query OK, 0 rows affected (0.09 sec) mysql> DELIMITER ;Call the stored procedure using CALL command −mysql> CALL select_statement();This will produce the following output −+-------------+ | FIRST VALUE | +-------------+ | HI          | +-------------+ 1 row in set (0.00 sec) +--------------+ | SECOND VALUE | +--------------+ | HELLO        | +--------------+ 1 row in set (0.01 sec) Query OK, 0 rows affected (0.01 sec)

Set Different IDs for Records Using a Single MySQL Query

AmitDiwan
Updated on 12-Dec-2019 06:09:41

197 Views

For conditions, use CASE statement in MySQL. Let us first create a table −mysql> create table DemoTable1545    -> (    -> Id int,    -> FirstName varchar(20)    -> ); Query OK, 0 rows affected (1.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1545 values(1, 'John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1545 values(2, 'Chris'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1545 values(3, 'Bob'); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select * from DemoTable1545;This will produce ... Read More

Remove Text Between Square Brackets in MySQL Query

AmitDiwan
Updated on 12-Dec-2019 06:08:50

974 Views

Let us first create a table −mysql> create table DemoTable    -> (    -> Name text    -> ); Query OK, 0 rows affected (0.47 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John [John] Smith'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values('[Carol] Carol Taylor'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('David [Miller] Miller'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output−+-----------------------+ | Name         ... Read More

Insert Multiple Data Using SET Clause in MySQL

AmitDiwan
Updated on 12-Dec-2019 06:07:52

156 Views

Let us first create a table −mysql> create table DemoTable1544    -> (    -> Id int ,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (2.47 sec)Insert some records in the table using insert command. We have inserted multiple data using SET clause −mysql> insert into DemoTable1544 set Id=101, Name='John Doe'; Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1544 set Id=102, Name='Adam Smith'; Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1544 set Id=103, Name='Chris Brown'; Query OK, 1 row affected (0.12 sec)Display all records from the table using select ... Read More

Advertisements