Found 4219 Articles for MySQLi

How can we enter numeric values as Hexadecimal (HEX) number in MySQL statement?

radhakrishna
Updated on 22-Jun-2020 12:23:10

124 Views

Following are the two approaches with the help of which we can enter numeric values as a Hexadecimal number −By prefix ‘X’In this approach we need to quote hexadecimal numbers within single quotes with a prefix of X. Then HEX number string will be automatically converted into a number based on the expression context.Examplemysql> Select X'5152545678'+ 10; +-------------------+ | X'5152545678'+ 10 | +-------------------+ | 349273609858      | +-------------------+ 1 row in set (0.00 sec)By prefix 0xIn this approach, we need to write hexadecimal numbers without any quotes with a prefix of 0x. Then HEX number string will be automatically ... Read More

How can we enter characters as Hexadecimal (HEX) number in MySQL statement?

mkotla
Updated on 22-Jun-2020 12:25:02

804 Views

Following are the two approaches with the help of which we can enter characters as a Hexadecimal number −By prefix ‘X’In this approach we need to quote hexadecimal numbers within single quotes with a prefix of X. Then HEX number string will be automatically converted into a character string.Examplemysql> Select X'5152545678'; +---------------+ | X'5152545678' | +---------------+ | QRTVx         | +---------------+ 1 row in set (0.00 sec)By prefix 0xIn this approach, we need to write hexadecimal numbers without any quotes with a prefix of 0x. Then HEX number string will be automatically converted into a character string.Examplemysql> ... Read More

How can we escape special characters in MySQL statement?

Nishtha Thakur
Updated on 22-Jun-2020 12:24:08

897 Views

Sometimes we need to include special characters in a character string and at that time they must be escaped or protected. We need to pursue some basic rules for escaping special characters which are given below −The escape character (\) can be escaped as (\)Examplemysql> Select 'A\B'; +-----+ | A\B | +-----+ | A\B | +-----+ 1 row in set (0.00 sec)

In which order MySQL will invoke the triggers if we created multiple triggers of same event and action time?

Chandu yadav
Updated on 22-Jun-2020 12:13:23

197 Views

In this case, MySQL will invoke the triggers in the order in which they are created. But with the help of following options, we can change the order −FOLLOWS optionThis option allows the new trigger to activate after the existing trigger.SyntaxFOR EACH ROW FOLLOWS trigger_namePRECEDES optionThis option allows the new trigger to activate before the existing trigger.SyntaxFOR EACH ROW PRECEDES trigger_name

How can we create multiple MySQL triggers for the same trigger event and action time?

Ayyan
Updated on 22-Jun-2020 12:11:45

513 Views

MySQL 5.7.2+ allows us to create multiple triggers for the same event and action time in a table. Both the triggers will activate sequentially when the event occurs. It can be understood with the help of an example −ExampleIn this example,  we are creating multiple triggers for the same event say BEFORE UPDATE. The names of the triggers are ‘Studentdetail_before_update’ and ‘Studentdetail_before_update2’. They will activate sequentially when an event occurs. We are creating these triggers on the table ‘Student_detail’ having the following data −mysql> Select * from Student_detail; +-----------+-------------+------------+ | Studentid | StudentName | address    | +-----------+-------------+------------+ | 100     ... Read More

Why do we need to change the delimiter for creating a trigger?

Swarali Sree
Updated on 22-Jun-2020 12:15:45

408 Views

As we know that in MySQL we use the delimiter semicolon (;) to end each statement. The semicolon is the by default delimiter in MySQL. We need to change the delimiter, while creating a trigger, to tell MySQL that this is not the end of our trigger statement because we can use multiple statements in the trigger. We can change the delimiter temporarily by DELIMITER // statement to change the delimiter from Semicolon (;) to two back-slash (//). After this MySQL would know that the triggering statement only ends when it encounters a two back-slash (//). Following is an example ... Read More

How can I check the tables of databases other than current database?

Giri Raju
Updated on 22-Jun-2020 12:14:06

71 Views

With the help of following MySQL command, we can check the tables of a database other than the database we are currently using −Show Tables from Database_name;For example, the following query would display the list of tables from a database named ‘gaurav’ when currently we are using a database named ‘new’ −mysql> use new; Database changed mysql> show tables from gaurav; +--------------------+ | Tables_in_tutorial | +--------------------+ | testing            | | employee           | | tender             | | Ratelist           | +--------------------+ 4 rows in set (0.00 sec)

How can I get the records from MySQL table in result set in a particular way?

Sreemaha
Updated on 22-Jun-2020 12:16:48

157 Views

For getting the records from MySQL table in the result set in a particular way either ascending or descending, we need to use the ORDER BY clause along with ASC or DESC keywords. If we will not use any of the above-mentioned keywords then MySQL by default return the records in ascending order. The ORDER BY clause returned the result set based on a particular field (ascending or descending order) with which we will use the ORDER BY clause. Suppose we want to sort the rows of the following table −mysql> Select * from Student; +--------+--------+--------+ | Name   | ... Read More

How Can we use MySQL DISTINCT clause with WHERE and LIMIT clause?

Nikitha N
Updated on 22-Jun-2020 12:17:19

5K+ Views

By using the WHERE clause with a DISTINCT clause in MySQL queries, we are putting a condition on the basis of which MySQL returns the unique rows of the result set. By using the LIMIT clause with a DISTINCT clause in MySQL queries, we are actually providing a perimeter to the server about a maximum number of unique rows of the result set to be returned.ExampleWe can use WHERE and LIMIT clause with DISTINCT as follows on the table named ‘testing’ −mysql> Select * from testing; +------+---------+---------+ | id   | fname   | Lname   | +------+---------+---------+ |  200 ... Read More

How OLD and NEW keywords enable us to access columns in row affected bya trigger?

Sai Subramanyam
Updated on 30-Jul-2019 22:30:21

577 Views

As we know that in trigger definition, we can refer to columns of the row being inserted, updated or deleted. Following are the ways OLD and NEW keywords enable us to access columns − We must have to prefix the column name with a qualifier of OLD to refer to a value from the original row. We must have to prefix the column name with a qualifier of NEW to refer to a value in the new row. Now, the use of OLD and NEW must be done appropriately because the triggering event Determines which of them are ... Read More

Advertisements