- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4219 Articles for MySQLi
9K+ Views
Yes, it is possible to use MySQL GROUP BY clause with multiple columns just as we can use MySQL DISTINCT clause. Consider the following example in which we have used DISTINCT clause in first query and GROUP BY clause in the second query, on ‘fname’ and ‘Lname’ columns of the table named ‘testing’.mysql> Select * from testing; +------+---------+---------+ | id | fname | Lname | +------+---------+---------+ | 200 | Raman | Kumar | | 201 | Sahil | Bhalla | | 202 | Gaurav | NULL | | 203 | Aarav | ... Read More
431 Views
When we use the GROUP BY clause in the SELECT statement without using aggregate functions then it would behave like the DISTINCT clause. For example, we have the following table −mysql> Select * from testing; +------+---------+---------+ | id | fname | Lname | +------+---------+---------+ | 200 | Raman | Kumar | | 201 | Sahil | Bhalla | | 202 | Gaurav | NULL | | 203 | Aarav | NULL | | 204 | Harshit | Khurana | | 205 | Rahul | NULL | | 206 | ... Read More
5K+ Views
We can use the DISTINCT clause on more than columns in MySQL. In this case, the uniqueness of rows in the result set would depend on the combination of all columns.ExampleConsider the following table ‘testing’ having 10 rows −mysql> select * from testing; +------+---------+---------+ | id | fname | Lname | +------+---------+---------+ | 200 | Raman | Kumar | | 201 | Sahil | Bhalla | | 202 | Gaurav | NULL | | 203 | Aarav | NULL | | 204 | Harshit | Khurana | | 205 | Rahul ... Read More
296 Views
We can destroy a trigger in two ways −Dropping a trigger explicitlyWith the help of the DROP statement, we can destroy a trigger explicitly. It can be understood with the help of the following example −mysql> DROP Trigger before_inser_studentage1; Query OK, 0 rows affected (0.05 sec)Dropping a trigger implicitlyA trigger will be destroyed implicitly if the table with which it is associated is destroyed or if the database which it is associated is destroyed.
1K+ Views
While querying data from a MySQL table, we may get duplicate values from a column. With the help of the DISTINCT clause in the SELECT statement, we can get rid of duplicate data in the result set.SyntaxSELECT DISTINCT Columns FROM Table_name WHERE conditions;ExampleFor example, we have a table named ‘tender’ having the following columns −mysql> Select * from tender; +----------+--------------+--------------+-------+ | clientid | client_Fname | Client_Lname | value | +----------+--------------+--------------+-------+ | 100 | Mohan | Kumar | 60000 | | 101 | Sohan | Singh ... Read More
184 Views
By using DISTINCT keyword along with column name as the argument of COUNT() function we can count the number of unique values in a column. The syntax is as follows − SELECT COUNT(DISTINCT Col_name) FROM table_name; Example Suppose we have the following table mysql> Select * from tender; +----------+--------------+--------------+-------+ | clientid | client_Fname | Client_Lname | value | +----------+--------------+--------------+-------+ | 100 | Mohan | Kumar | 60000 | | 101 | Sohan ... Read More
172 Views
We must have SUPER privileges to create or destroy triggers with the help of a CREATE or DROP statement. Other than that if the triggered statements use OLD or NEW then there are some additional privileges as follows which we require −To assign the value of a column with SET NEW.column_name = value then we must have the UPDATE privilege for the column.To use NEW.column_name in an expression to refer to the new value of a column, we must have the SELECT privilege for the column.
71 Views
We can find all the triggers associated with a particular table with the help of the following query −mysql> Select * from INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_SCHEMA = 'query'AND EVENT_OBJECT_TABLE = 'Student_info'\G *************************** 1. row *************************** TRIGGER_CATALOG: def TRIGGER_SCHEMA: query TRIGGER_NAME: studentinfo_after_delete EVENT_MANIPULATION: DELETE EVENT_OBJECT_CATALOG: def EVENT_OBJECT_SCHEMA: query EVENT_OBJECT_TABLE: student_info ACTION_ORDER: 1 ACTION_CONDITION: NULL ... Read More
84 Views
It can be done with the help of the following statement −mysql> select * from information_schema.triggers where -> information_schema.triggers.trigger_schema like '%query%'\G *************************** 1. row *************************** TRIGGER_CATALOG: def TRIGGER_SCHEMA: query TRIGGER_NAME: trigger_before_delete_sample EVENT_MANIPULATION: DELETE EVENT_OBJECT_CATALOG: def EVENT_OBJECT_SCHEMA: query EVENT_OBJECT_TABLE: sample ACTION_ORDER: 1 ACTION_CONDITION: NULL ACTION_STATEMENT: BEGIN SET @count ... Read More
125 Views
It can be done with the help of the INFORMATION_SCHEMA database. Following statement will give us the metadata of triggers −mysql> Select trigger_schema, trigger_name, action_statement -> from information_schema.triggers\G *************************** 1. row *************************** trigger_schema: query trigger_name: trigger_before_delete_sample action_statement: BEGIN SET @count = if (@count IS NULL, 1, (@count+1)); INSERT INTO sample_rowaffected values (@count); END *************************** 2. row *************************** trigger_schema: query trigger_name: before_inser_studentage action_statement: IF NEW.age < 0 THEN SET NEW.age = 0; END IF *************************** 3. row *************************** trigger_schema: sys trigger_name: sys_config_insert_set_user action_statement: BEGIN IF @sys.ignore_sys_config_triggers != true AND NEW.set_by ... Read More