Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 25 of 81

Role of CSS :focus Selector

Chandu yadav
Chandu yadav
Updated on 30-Jun-2020 178 Views

Use the :focus selector to select the element that has focus. You can try to run the following code to implement the :focus selectorExample                    input:focus {             background-color: green;          }                              Subject          Student:          Age:                    

Read More

Fletcher’s Checksum

Chandu yadav
Chandu yadav
Updated on 30-Jun-2020 6K+ Views

Fletcher checksum is an error – detection technique that uses two checksums to determine single-bit errors in a message transmitted over network channels. It is a block code technique that was devised by John G. Fletcher in 1970s at Lawrence Livermore Labs, USA.The checksums are created based on the data values in the data blocks to be transmitted and appended to the data. When the receiver gets this data, the checksums are re-calculated and compared with the existing checksums. A non-match indicates an error.The error-detection capabilities of this method is nearly same as that of Cyclic Redundancy Check (CRC) but ...

Read More

Change date format (in DB or output) to dd/mm/yyyy in PHP MySQL?

Chandu yadav
Chandu yadav
Updated on 30-Jun-2020 3K+ Views

You can change the date format in PHP using date() fucntion. The syntax is as follows −date(d/m/Y, yourDateTimeVariable);In PHP, convert string to date using strtodate(). Here is the PHP code used to format the datetime −$LogintDate = strtotime('2019-01-12'); echo date('d/m/Y', $LogintDate);The snapshot of code is as follows −The following is the output −12/01/2019You can achieve in MySQL with the help of date_format() function. The syntax is as follows −SELECT DATE_FORMAT(yourColumnName, ’%d/%m/%Y’) as anyVariableName FROM yourTableName;To understand the above syntax, let us create a table −mysql> create table Date_FormatDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> ...

Read More

How to map keys to values for an individual field in a MySQL select query?

Chandu yadav
Chandu yadav
Updated on 30-Jun-2020 3K+ Views

You can use CASE statement in MySQL to map keys to values for an individual field in select query. The syntax is as follows −SELECT yourColumnName1, yourColumnName2, yourColumnName3, .........N (    CASE WHEN yourColumnName = 1 THEN 'ENABLED'    ELSE 'DISABLED'    END ) AS anyVariableName FROM yourTableName;You can use IF() function also for the same purpose. The syntax is as follows −SELECT yourColumnName1, yourColumnName2, yourColumnName3, .........N ,IF(yourColumnName, 'ENABLED', 'DISABLED') as anyVariableName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table MapKeys    -> (   ...

Read More

Is `definer` required when creating a MySQL stored procedure?

Chandu yadav
Chandu yadav
Updated on 30-Jun-2020 2K+ Views

No, definer part is not compulsory when you are creating a stored procedure. It is used when you want to create a definer.Check all the user and host from the MySQL.user table −mysql> select user, host from mysql.user;The following is the output −+------------------+-----------+ | user             | host      | +------------------+-----------+ | Manish           | %         | | User2            | %         | | mysql.infoschema | %         | | mysql.session    | %   ...

Read More

MySQL BETWEEN without the beginning and endpoints?

Chandu yadav
Chandu yadav
Updated on 30-Jun-2020 126 Views

If you do not want to include start and end value in between, then use the following syntax −SELECT * FROM yourTableName WHERE yourColumnName BETWEEN yourStartingValue and yourEndingValue and    yourColumnName not in (yourStartingValue , yourEndingValue );To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table BetweenWithoutEndPoints    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(20),    -> Age int,    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.54 sec)Now you can insert some records in the table using ...

Read More

Insert sequential number in MySQL?

Chandu yadav
Chandu yadav
Updated on 30-Jun-2020 1K+ Views

You can insert sequential number in MySQL using session variable. The syntax is as follows −SELECT @anyVariableName − = anyIntegerValue; UPDATE yourTableName SET yourColumnName = @anyVariableName − = @anyVariableName+IncrementStep;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table SequentialNumberDemo    -> (    -> SequentialNumber int not null    -> ); Query OK, 0 rows affected (0.84 sec)Insert records in the table using insert command. The query is as follows −mysql> insert into SequentialNumberDemo values(100); Query OK, 1 row affected (0.11 sec) mysql> insert into SequentialNumberDemo values(10); ...

Read More

How to add static value while INSERT INTO with SELECT in a MySQL query?

Chandu yadav
Chandu yadav
Updated on 30-Jun-2020 13K+ Views

You can add static value when you use INSERT INTO SELECT MySQL query. Write the value directly in the select statement or you can add with the help of variable which initializes the value.Case 1 − Place the value directly in the INSERT INTO SELECT statement. The syntax is as follows −INSERT INTO yourSecondTableName(yourColumnName1, yourColumnName2, ....N)    SELECT yourColumnName1 ,yourColumnName2, .....N, yourStaticValue from yourFirstTableName;Case 2 − Add using variable. The syntax is as follows −SET @yourVariableName − = yourstaticValue;    INSERT INTO yourSecondTableName(yourColumnName1, yourColumnName2, ....N)    SELECT yourColumnName1 ,yourColumnName2, .....N, @yourVariableName from yourFirstTableName;To understand the above syntax, you need to ...

Read More

How to Insert custom date into MySQL timestamp field?

Chandu yadav
Chandu yadav
Updated on 30-Jun-2020 2K+ Views

The problem with UNIX_TIMESTAMP() function is that it returns an integer while we want to insert custom date i.e. not any integer part to MySQL date.Do not use UNIX_TIMESTAMP() for your column defined as TIMESTAMP because UNIX_TIMESTAMP() returns an integer.Check the UNIX_TIMESTAMP. The query is as follows −mysql> select UNIX_TIMESTAMP( '2019-01-09 15 −48 −23') AS IntegerValue;The following is the output −+--------------+ | IntegerValue | +--------------+ | 1547029103   | +--------------+ 1 row in set (0.00 sec)Look at the sample output, the UNIX_TIMESTAMP() function returns an integer of corresponding date and time.The syntax is as follows to insert custom date for ...

Read More

MySQL Order By specific strings?

Chandu yadav
Chandu yadav
Updated on 30-Jun-2020 811 Views

Order by the choice of strings you want, using the FIELD() function. The syntax is as follows −SELECT *FROM yourTableName ORDER BY FIELD(yourColumnName, ’yourValue1’, ’yourValue2’, ’yourValue3’, ....N);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table OrderByListOfStrings    -> (    -> Id int not null auto_increment,    -> CarName varchar(20),    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into OrderByListOfStrings(CarName) values('Ford'); Query OK, 1 row affected ...

Read More
Showing 241–250 of 810 articles
« Prev 1 23 24 25 26 27 81 Next »
Advertisements