AmitDiwan has Published 10744 Articles

Return list of databases in MySQL?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 06:31:43

216 Views

To return list of databases, the syntax is as follows −select schema_name as anyAliasName from information_schema.schemata;Here is the query to return list of databases in MySQL −mysql> select schema_name as DatabaseName from information_schema.schemata;This will produce the following output −+---------------------------+ | DatabaseName              | +---------------------------+ | ... Read More

Update two columns with a single MySQL query

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 06:28:05

526 Views

For this, you need to use SET command only once. Let us first create a table −mysql> create table DemoTable1909    (    Id int NOT NULL,    FirstName varchar(20),    LastName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command ... Read More

How to escape parentheses in MySQL REGEXP clause and display only specific values with parentheses?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 06:26:07

849 Views

Let us first create a table −mysql> create table DemoTable1908    (    Code text    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1908 values('MySQL(1)Database'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1908 values('MongoDB 2 ... Read More

Create table query with manual AUTO_INCREMENT start value in MySQL?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 06:24:21

170 Views

Let us first create a table −mysql> create table DemoTable1907    (    UserId int NOT NULL AUTO_INCREMENT,    UserName varchar(20),    UserAge int,    UserCountryName varchar(20),    PRIMARY KEY(UserId)    )ENGINE=MyISAM, AUTO_INCREMENT=100; Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert ... Read More

How to change format of dates in a table column with a MySQL query?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 06:22:02

463 Views

To change format of dates, use the DATE_FORMAT() function. Let us first create a table −mysql> create table DemoTable1906    (    DueTime datetime    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1906 values(now()); Query OK, 1 row ... Read More

MySQL Count Distinct values process is very slow. How to fasten it?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 06:20:28

380 Views

To fasten the process, you can use INDEX. Let us first create a table −mysql> create table DemoTable1905    (    FirstName varchar(20),    LastName varchar(20) ,    INDEX F_L_Name(FirstName, LastName)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert ... Read More

How to escape backslashes in MySQL with JDBC?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 06:17:55

400 Views

To escape backslashes, use PreparedStatement while inserting records. Let us first create a table −mysql> create table DemoTable1904    (    ClientId int,    ClientName varchar(20),    ClientAge int    ); Query OK, 0 rows affected (0.00 sec)The Java code is as follows −import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; public ... Read More

MySQL UPDATE column names and set None values with N/A?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 06:14:54

281 Views

Let us first create a table −mysql> create table DemoTable1903    (    FirstName varchar(20),    LastName varchar(20) ,    Age int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1903 values('John', 'Smith', 23); Query OK, 1 row ... Read More

Text Transformation using CSS

AmitDiwan

AmitDiwan

Updated on 27-Dec-2019 09:52:30

100 Views

For text transformation in CSS, use the text-transform property with the following values −text-transform: none|capitalize|uppercase|lowercase|initial|inherit;Example Live Demo div {    line-height: 1.9;    text-transform: uppercase; } Demo Heading This is demo text. This is another demo text. OutputExampleLet us see another ... Read More

How to strip all spaces out of a string in PHP?

AmitDiwan

AmitDiwan

Updated on 27-Dec-2019 09:20:30

368 Views

To strip all spaces out of a string in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−ThisisateststrinTo remove the whitespaces only, the below code can be used−Example Live DemoOutputThis will produce the following output. The str_replace function replaces the given input string with a specific character or ... Read More

Advertisements