AmitDiwan has Published 11365 Articles

HTML onpaste Event Attribute

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 07:22:51

160 Views

The HTML onpaste attribute is triggered when user paste some content in an HTML element in an HTML document.SyntaxFollowing is the syntax −Let us see an example of HTML onpaste event Attribute −Example Live Demo    body {       color: #000;       height: 100vh; ... Read More

Limit the count using GROUP BY in MySQL

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 07:20:43

997 Views

Let us first create a table −mysql> create table DemoTable (    UserId int,    UserMessage varchar(100) ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1, 'Hi'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable ... Read More

How to get MySQL query result in same order as given by IN clause?

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 07:18:18

986 Views

For this, you can use IN() along with ORDER BY FIELD(). Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(100) ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> ... Read More

How to display all the MySQL tables in one line?

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 07:15:49

388 Views

Use information_schema.tables to display all the tables. With that, se the database name as well, so that you can display tables only from a specific database.Let us now display all the tables in the database “web” −mysql> select group_concat(table_name) from information_schema.tables where table_schema='web';This will produce the following output −+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ... Read More

How to select all the characters after the first 20 characters from a column in MySQL?

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 07:11:59

169 Views

Let us first create a table −mysql> create table DemoTable (    Title text ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('C is a good programming language to start'); Query OK, 1 row affected (0.18 sec) mysql> ... Read More

MySQL query to find single value from duplicates with certain condition by excluding other records using NOT IN

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 07:08:35

56 Views

Let us first create a table −mysql> create table DemoTable (    Id int,    FirstName varchar(100) ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable ... Read More

Underscore as a table name in MySQL is possible?

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 07:05:44

180 Views

Yes, we can add underscore as a table name using backticks around the table name. Following is the syntax −INSERT INTO `yourTableName` values(yourValue1, .......N);Let us first create a table −mysql> create table `DemoTable_1` (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Location varchar(100) ); Query OK, 0 rows ... Read More

Delete records from a MySQL table by excluding non-deleted records using NOT IN

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 07:03:44

124 Views

Let us first create a table −mysql> create table DemoTable (    FirstName varchar(100) ); Query OK, 0 rows affected (0.65 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('Robert'); Query OK, 1 ... Read More

Return only the first 15 characters from a column with string values in MySQL

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 07:01:47

484 Views

To return only the first 15 characters from string values, use the MySQL SUBSTR() function.Let us first create a table −mysql> create table DemoTable (    Title varchar(100) ); Query OK, 0 rows affected (0.69 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Introduction to ... Read More

Add a percentage (%) sign at the end to each value while using MySQL SELECT statement

AmitDiwan

AmitDiwan

Updated on 26-Sep-2019 06:59:14

3K+ Views

To add percentage sign at the end, use CONCAT() function. Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(100),    StudentScore int ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert ... Read More

Advertisements