Found 4219 Articles for MySQLi

How can we RENAME an existing MySQL event?

Paul Richard
Updated on 22-Jun-2020 12:33:25

116 Views

With the help of ALTER EVENT statement along with the RENAME keyword, we can RENAME an existing event. To illustrate it we are having the following example in which we are renaming the event ‘Hello’ to ‘Hello_renamed’ −Examplemysql> ALTER EVENT Hello RENAME TO Hello_renamed; Query OK, 0 rows affected (0.00 sec)To confirm that event has been renamed we can try to delete the event with the old name, MySQL will throw an error as follows −mysql> DROP EVENT hello; ERROR 1539 (HY000): Unknown event 'hello'

How can we ENABLE AND DISABLE a particular MySQL event?

Sai Nath
Updated on 22-Jun-2020 12:38:29

2K+ Views

With the help of ALTER EVENT statement along with the ENABLE and DISABLE keyword, we can ENABLE and DISABLE the event. To illustrate it we are having the following example −Examplemysql> ALTER EVENT hello DISABLE; Query OK, 0 rows affected (0.00 sec)The above query will DISABLE the event named ‘Hello’ and the query below will enable it.mysql> ALTER EVENT hello ENABLE; Query OK, 0 rows affected (0.00 sec)

How can we modify an existing MySQL event?

Samual Sam
Updated on 22-Jun-2020 12:34:23

359 Views

With the help of ALTER EVENT statement, we can modify an existing MySQL event. We can change the various attributes of an event. ALTER EVENT has the following syntax −   ALTER EVENT event_name     ON SCHEDULE schedule ON COMPLETION [NOT] PRESERVE   RENAME TO new_event_name     ENABLE | DISABLE            DO        event_bodyTo understand it we are illustrating the example as below −ExampleSuppose we have an event as follows −mysql> Create event hello ON SCHEDULE EVERY 1 Minute DO INSERT INTO event_messages(message, generated_at) Values ('Alter event testing', NOW()); Query OK, 0 rows ... Read More

How can we delete an existing MySQL event permanently?

Anjana
Updated on 22-Jun-2020 12:26:04

248 Views

We need to use the DROP statement to delete an existing MySQL event permanently. To illustrate it we are deleting the event named testing_event as follows −Examplemysql> DROP EVENT testing_event; Query OK, 0 rows affected (0.00 sec)

How can we simulate the MySQL INTERSECT query returning multiple expressions?

Giri Raju
Updated on 22-Jun-2020 12:35:18

145 Views

Since we cannot use the INTERSECT query in MySQL, we will use the EXIST operator to simulate the INTERSECT query. It can be understood with the help of the following example −ExampleIn this example, we are two tables namely Student_detail and Student_info having the following data −mysql> Select * from Student_detail; +-----------+---------+------------+------------+ | studentid | Name    | Address    | Subject    | +-----------+---------+------------+------------+ |       101 | YashPal | Amritsar   | History    | |       105 | Gaurav  | Chandigarh | Literature | |       130 | Ram     ... Read More

How can we simulate the MySQL INTERSECT query having WHERE clause?

Abhinaya
Updated on 22-Jun-2020 12:49:51

141 Views

Since we cannot use INTERSECT query in MySQL, we will use IN operator to simulate the INTERSECT query. It can be understood with the help of the following example −ExampleIn this example, we are two tables namely Student_detail and Student_info having the following data −mysql> Select * from Student_detail; +-----------+---------+------------+------------+ | studentid | Name    | Address    | Subject    | +-----------+---------+------------+------------+ |       101 | YashPal | Amritsar   | History    | |       105 | Gaurav  | Chandigarh | Literature | |       130 | Ram     | Jhansi ... Read More

How can we simulate the MySQL INTERSECT query?

Jennifer Nicholas
Updated on 22-Jun-2020 12:50:41

174 Views

Since we cannot use INTERSECT query in MySQL, we will use IN operator to simulate the INTERSECT query. It can be understood with the help of the following example −ExampleIn this example, we are two tables namely Student_detail and Student_info having the following data −mysql> Select * from Student_detail; +-----------+---------+------------+------------+ | studentid | Name    | Address    | Subject    | +-----------+---------+------------+------------+ | 101       | YashPal | Amritsar   | History    | | 105       | Gaurav  | Chandigarh | Literature | | 130       | Ram     | Jhansi ... Read More

How to delete the duplicate values stored in reverse order from MySQL table?

Govinda Sai
Updated on 22-Jun-2020 12:35:57

255 Views

To understand this concept, we are using the data from table ‘Details_city’ as follows −mysql> Select * from details_city; +--------+--------+ | City1  | City2  | +--------+--------+ | Delhi  | Nagpur | | Delhi  | Mumbai | | Nagpur | Delhi  | | Katak  | Delhi  | | Delhi  | Katak  | +--------+--------+ 5 rows in set (0.00 sec)Now, the following query will delete the reverse duplicate values from details_city table −mysql> Select a.city1,a.city2 from details_city a WHERE a.city1

How can we find the employees from MySQL table whose age is greater than say 30 years, providing the only date of birth on the table?

Vrundesha Joshi
Updated on 22-Jun-2020 12:37:37

1K+ Views

To understand this concept, we are using the data from table ‘emp_tbl’ as follows −mysql> Select * from emp_tbl; +--------+------------+ | Name   | DOB        | +--------+------------+ | Gaurav | 1984-01-17 | | Gaurav | 1990-01-17 | | Rahul  | 1980-05-22 | | Gurdas | 1981-05-25 | | Naveen | 1991-04-25 | | Sohan  | 1987-12-26 | +--------+------------+ 6 rows in set (0.00 sec) mysql> SELECT Name, SYSDATE(), DOB, DATEDIFF(SYSDATE(), DOB)/365 AS AGE from emp_tbl WHERE(DATEDIFF(SYSDATE(), DOB)/365)>30; +--------+---------------------+------------+---------+ | Name   | SYSDATE()           | DOB        | AGE   ... Read More

How can we fetch a second highest salary of an employee from a MySQL table?

Ramu Prasad
Updated on 22-Jun-2020 12:39:06

193 Views

To understand this concept, we are using the data from table ‘Salary’ as follows −mysql> Select * from Salary; +--------+--------+ | Name   | Salary | +--------+--------+ | Gaurav |  50000 | | Rahul  |  40000 | | Ram    |  45000 | | Raman  |  45000 | +--------+--------+ 4 rows in set (0.00 sec) mysql> Select * from salary12345 order by salary DESC limit 1 offset 1; +-------+--------+ | name  | Salary | +-------+--------+ | Raman |  45000 | +-------+--------+ 1 row in set (0.00 sec)

Advertisements