AmitDiwan has Published 10740 Articles

Update two columns with a single MySQL query

AmitDiwan

AmitDiwan

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

553 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

877 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

190 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

491 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

409 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

425 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

311 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

402 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

Is it possible to combine PHP's filter_input() filter flags with AND/OR?

AmitDiwan

AmitDiwan

Updated on 27-Dec-2019 09:19:05

194 Views

Yes, it is possible to combine filter_input() with AND/OR in PHP. This can be done by looping over the POST fields−$value = filter_input(INPUT_POST, 'field', FILTER_DEFAULT, is_array($_POST['field']) ? FILTER_REQUIRE_ARRAY : NULL);An equivalent for the same user for each loop has been shown below−$memory = array(); //looping through all posted values foreach($_POST ... Read More

Advertisements