AmitDiwan has Published 10744 Articles

Concatenation of two strings in PHP program

AmitDiwan

AmitDiwan

Updated on 24-Dec-2019 12:13:08

238 Views

To concatenate two strings in PHP, the code is as follows −Example Live DemoOutputThis will produce the following output−1.967 and 1.969 Both the values are equal!ExampleLet us now see another example − Live DemoOutputThis will produce the following output−First Name = Jack Second Name = Sparrow Concatenation = JackSparrow

Comparing float value in PHP

AmitDiwan

AmitDiwan

Updated on 24-Dec-2019 12:10:38

752 Views

To compare float values in PHP, the code is as follows −Example Live DemoOutputThis will produce the following output−2.5 3.5 Both the values aren\'t equalExampleLet us now see another example − Live DemoOutputThis will produce the following example−1.967 1.969 Both the values are equal!

‘AND’ vs ‘&&’ operators in PHP

AmitDiwan

AmitDiwan

Updated on 24-Dec-2019 12:08:08

2K+ Views

The difference is the precedence when we compare AND with && operator. The precedence of AND operator is lower than the operator = when the evaluation is performed, therefore even if both the operators do the same work, the result is different.ExampleLet us first see an example of the AND ... Read More

How to connect Java to MySQL?

AmitDiwan

AmitDiwan

Updated on 24-Dec-2019 07:58:15

521 Views

To connect Java to MySQL, the Java code is as follows −import java.sql.Connection; import java.sql.DriverManager; public class LostConnectionURLDemo {    public static void main(String[] args){       String JDBCURL="jdbc:mysql://localhost:3306/web?autoReconnect=true";       Connection con=null;        try{           con = DriverManager.getConnection(JDBCURL, "root", "123456");   ... Read More

Sort search results based on substring position in MySQL

AmitDiwan

AmitDiwan

Updated on 24-Dec-2019 07:55:43

223 Views

To sort search results based on substring position, use ORDER BY LOCATE(). Let us first create a table −mysql> create table DemoTable1838      (      Subject varchar(100)      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

How to get a specific column record from SELECT query in MySQL?

AmitDiwan

AmitDiwan

Updated on 24-Dec-2019 07:54:20

486 Views

Let us first create a table −mysql> create table DemoTable1837      (      StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,      StudentName varchar(20)      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1837(StudentName) values('Chris'); Query ... Read More

Fix MySQL Error #1064 - You have an error in your SQL syntax… near 'TYPE=MyISAM?

AmitDiwan

AmitDiwan

Updated on 24-Dec-2019 07:52:21

798 Views

This error occurs when we use TYPE for ENGINE NAME. The error is as follows −mysql> create table DemoTable1836      (      ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,      ClientName varchar(20)      )Type=MyISAM AUTO_INCREMENT=1; ERROR 1064 (42000): You have an error in your SQL syntax; ... Read More

How to fetch random rows in MySQL with comma separated values?

AmitDiwan

AmitDiwan

Updated on 24-Dec-2019 07:51:07

208 Views

To fetch random rows in MySQL, use ORDER BY RAND(). Let us first create a table −mysql> create table DemoTable1835      (      ListOfIds varchar(20)      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1835 values('10, ... Read More

Select rows containing a string in a specific column with MATCH and AGAINST in MySQL

AmitDiwan

AmitDiwan

Updated on 24-Dec-2019 07:49:58

238 Views

Let us first create a table −mysql> create table DemoTable1833      (      Name varchar(20)      ); Query OK, 0 rows affected (0.00 sec)Alter table −Mysql> alter table DemoTable1833 ADD FULLTEXT(Name); Query OK, 0 rows affected, 1 warning (0.00 sec) Records: 0  Duplicates: 0  Warnings: 1Insert some ... Read More

Insert JSON into a MySQL table?

AmitDiwan

AmitDiwan

Updated on 24-Dec-2019 07:48:58

2K+ Views

Let us create a table and set a column value with type JSONmysql> create table DemoTable1832      (      ListOfNames JSON      ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1832(ListOfNames) values('["Sam", "Mike", "Carol"]'); Query OK, ... Read More

Advertisements