- 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 6702 Articles for Database
114 Views
Writing cross joins with the help of comma operator is the most basic way to combine two tables. As we know that we can also write cross join by using keyword CROSS JOIN or synonyms like JOIN. To form a cross join we do not need to specify the condition which is known as join-predicate To understand it, we are taking the example of two tables named tbl_1 and tbl_2 which are having following data −mysql> Select * from tbl_1; +----+--------+ | Id | Name | +----+--------+ | 1 | Gaurav | | 2 | Rahul | | 3 ... Read More
52 Views
MySQL NOT RLIKE operator can be used to check for a pattern which is not present within an expression. The syntax for NOT RLIKE is as follows − Syntax NOT RLIKE Pat_not_for_match Here Pat_not_for_match is the pattern which is not to be matched with the expression. Example mysql> Select Id, Name from Student WHERE Name NOT RLIKE '^H'; +------+---------+ | Id | Name | +------+---------+ | 1 | Gaurav | | 2 | Aarav | | 20 | Gaurav | ... Read More
52 Views
MySQL has function name REVERSE() with the help of which we can reverse the string. But suppose if we want to reverse the string connected by dash then by using REVERSE() function will not give appropriate result as shown in the following example:mysql> Select REVERSE('AB-CD-EF'); +---------------------+ | REVERSE('AB-CD-EF') | +---------------------+ | FE-DC-BA | +---------------------+ 1 row in set (0.00 sec)The appropriate result would be ‘EF-CD-AB’ and for getting such output we can use SUBSTRING_INDEX() function along with Instr() function. It is demonstrated as follows:mysql> Select CONCAT(SUBSTRING_INDEX('AB-CD-EF', '-', -1), '-', substr('AB-CD-EF', instr('AB-CD-EF', "-")+1, instr('AB-CD-EF', "-")), LEFT('AB-CD-EF', ... Read More
125 Views
Writing inner joins with the help of comma operator is the most basic way to combine two tables. As we know that we can also write inner join by using keyword INNER JOIN or synonyms like JOIN. To form an inner join we need to specify a particular condition which is known as join-predicate and while writing inner joins using the comma operator, we use WHERE clause, the only way, to specify the join condition. To understand it, we are taking the example of two tables named tbl_1 and tbl_2 which are having following data:mysql> Select * from tbl_1; +----+--------+ ... Read More
162 Views
Actually, in simple words, we can say that a join between tables is an extension of a single-table SELECT statement but it involves the additional complexities:Need to specify all the tablesWe need to specify all the tables in FROM clause which are involved in the join. It is in contrast with the SELECT statement in which only one table name is necessary.Need to specify the matching conditionsWe just need to specify the matching conditions based on which a join matches the records in one table with a record in another table. The conditions often are given in the WHERE clause, ... Read More
212 Views
MySQL REVERSE() function can have the column name as an argument to invert its value. If we want to apply some condition/s then it can be used along with WHERE clause as follows:Examplemysql> Select Name, REVERSE(Name) from Student; +---------+---------------+ | Name | REVERSE(Name) | +---------+---------------+ | Aarav | varaA | | Gaurav | varuaG | | Gaurav | varuaG | | Harshit | tihsraH | | Yashraj | jarhsaY | +---------+---------------+ 5 rows in set (0.00 sec)The above query inverts the values ... Read More
220 Views
With the help of MySQL string function ASCII(), we can get the number code of a particular character. Its syntax is ASCII(str) where, str, the argument of ASCII() function, is the string whose ASCII value of the first character to be retrieved.It will return the number code the left the most character i.e. first character of the string given as argument.Examplemysql> Select ASCII('T'); +------------+ | ASCII('T') | +------------+ | 84 | +------------+ 1 row in set (0.01 sec) mysql> Select ASCII('t'); +------------+ | ASCII('t') | +------------+ | 116 | +------------+ 1 row ... Read More
122 Views
MySQL REVERSE() function make it possible to invert a string. Its syntax is as follows −SyntaxREVERSE(STR)Here, STR is a string which we want to invert.Examplemysql> Select REVERSE('MySQL'); +------------------+ | REVERSE('MySQL') | +------------------+ | LQSyM | +------------------+ 1 row in set (0.05 sec)
1K+ Views
If we want to replace strings in multiple records then REPLACE() function must have the column name as 1st argument i.e. at the place of string. It means that, it will replace all the substring with another substring in that particular column. We can also use REPLACE() function with WHERE clause along with UPDATE statement to apply conditions. It is exhibit with the following example:Examplemysql> Update Student set Name = REPLACE(Name, 'G', 'S') WHERE Subject LIKE '%Comp%'; Query OK, 2 rows affected (0.08 sec) Rows matched: 2 Changed: 2 Warnings: 0The above query replaces strings in multiple records of Student ... Read More
834 Views
As we know that REPLACE () function is used to replace the occurrences of a substring with another substring within a string. We can also use REPLACE function with UPDATE statement to update the table by finding and replacing the data.Examplemysql> Update Student set Father_Name = REPLACE(Father_Name, 'Mr.', 'Shri '); Query OK, 5 rows affected (0.06 sec) Rows matched: 5 Changed: 5 Warnings: 0 mysql> Select Name, Father_Name from Student; +---------+-----------------+ | Name | Father_Name | +---------+-----------------+ | Gaurav | Shri Ramesh | | Aarav | Shri Sanjay | | Harshit ... Read More