Found 4219 Articles for MySQLi

How can we distinguish between MySQL CROSS JOIN and INNER JOIN?

seetha
Updated on 20-Jun-2020 11:06:05

285 Views

We can distinguish between MySQL CROSS JOIN and INNER JOIN only on the basis of join-predicate i.e. the condition specified. While writing the query for INNER JOIN we need to specify the condition but in contrast, we do not need to specify the condition while writing a query for CROSS JOIN. 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  | Raman  | | 4 ... Read More

How can we write MySQL query for cross joins with the help of Comma operator?

Daniol Thomas
Updated on 20-Jun-2020 11:06:48

113 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

In MySQL, how to check for a pattern which is not present within an expression?

George John
Updated on 30-Jul-2019 22:30:21

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

How can we reverse a MySQL string connected by the dash?

Monica Mona
Updated on 07-Feb-2020 11:10:47

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

How can we write MySQL query for inner joins with the help of Comma operator?

mkotla
Updated on 07-Feb-2020 11:08:27

124 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

What are the complexities MySQL joins involve?

Giri Raju
Updated on 30-Jul-2019 22:30:21

159 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

How can we use MySQL REVERSE() function on column’s data along with WHERE clause?

Ayyan
Updated on 07-Feb-2020 10:45:56

211 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

In MySQL, how can we get the number code of a particular character?

Sharon Christine
Updated on 07-Feb-2020 10:45:12

218 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

How can it be possible to invert a string in MySQL?

Arushi
Updated on 20-Jun-2020 10:52:21

120 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)

How MySQL REPLACE() function replaces strings in multiple records?

Arjun Thakur
Updated on 07-Feb-2020 10:43:24

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

Advertisements