Found 4219 Articles for MySQLi

Write down the MySQL query which shows inequality condition?

Chandu yadav
Updated on 12-Feb-2020 07:09:16

68 Views

Inequality means NOT EQUAL TO and MySQL have two inequality operator, ‘’ and ‘!=’. following MySQL queries shows the inequality conditionsmysql> Select tender_value From estimated_cost1 WHERE Name_company != 'Chd Ltd.';The above query shows inequality condition because it have != operator.mysql> Select tender_value From estimated_cost1 WHERE Name_company 'Chd Ltd.';The above query shows inequality condition because it have operator.

Write down the MySQL query which shows equality condition?

Kumar Varma
Updated on 22-Jun-2020 06:24:12

68 Views

The binary equality operators compare their operands for strict equality or inequality. In MySQL, the equal-to-operator (=) returns 1 if both the operands have the same value otherwise returns 0. Following MySQL query show an equality condition −mysql> Select tender_value From estimated_cost WHERE id = 3;The above query shows an equality condition because the column id equates to the integer value.mysql> Select tender_value From estimated_cost1 WHERE Name_company = 'Chd Ltd.';The above query shows an equality condition because column Name_company equates to the string value.

How can we fetch a MySQL SET column as a list of integer offset?

Monica Mona
Updated on 22-Jun-2020 06:25:01

255 Views

We can fetch the MySQL SET column values as a list of integer offset with the help of the MAKE_SET() function. To make it understand, we are creating a table named ‘set_testing’ as follows −mysql> Create table set_testing( id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, table SET('ABC', 'ABD', 'GHF') NOT NULL); Query OK, 0 rows affected (0.08 sec) mysql> Insert into set_testing (table) values('1'); Query OK, 1 row affected (0.06 sec) mysql> Insert into set_testing (table) values('2'); Query OK, 1 row affected (0.06 sec) mysql> Insert into set_testing (table) values('3'); Query OK, 1 row affected (0.02 ... Read More

How can MySQL REPLACE() function be used with WHERE clause?

Sharon Christine
Updated on 22-Jun-2020 06:25:31

2K+ Views

As we know that WHERE clause is used to put condition/s in MySQL query and MySQL returns result set based on those conditions. Similarly when we use REPLACE() function with WHERE clause, the result set will depend upon the conditions provided. Following is an example by using data from the ‘Student’ table in which REPLACE() function replaces the records of a column ‘Name’ in which the value of column ‘Subject’ is ‘Computers’.Examplemysql> Select Name, REPLACE(Name, 'G', 'S') from student Where Subject = 'Computers'; +--------+------------------------+ | Name   | REPLACE(Name, 'G', 'S') | +--------+------------------------+ | Gaurav | Saurav       ... Read More

How can MySQL FIND_IN_SET() function be used to get the particular record(s) from the table as a result set?

Sai Nath
Updated on 12-Feb-2020 07:15:29

130 Views

We can get the record(s) as a result set by providing the particular string and name of the column as arguments of FIND_IN_SET() function. We also need to use WHERE clause with FIND_IN_SET() function. To understand it, we are using the data, given as below, from table ‘student_info’:mysql> Select * from student_info; +------+---------+----------+------------+ | id   | Name    | Address  | Subject    | +------+---------+----------+------------+ | 101  | YashPal | Amritsar | History    | | 105  | Gaurav  | Jaipur   | Literature | | 125  | Raman  | Shimla    | Computers  | +------+---------+----------+------------+ 3 rows in ... Read More

In function INSERT(str, Pos, len, newstr), what would be the result if ‘len’ is not within the length of the rest of string?

Ayyan
Updated on 22-Jun-2020 06:05:15

51 Views

In case if ‘len’ is not within the length of the rest of the string then MySQL INSERT() function will continue to remove the characters until the end of the original string.Examplemysql> Select INSERT('myteststring',3,15,'name'); +------------------------------------+ | INSERT('myteststring',3,15,'name') | +------------------------------------+ | myname                             | +------------------------------------+ 1 row in set (0.00 sec)

In function INSERT(str, Pos, len, newstr), what would be the result if ‘Pos’ is not within the length of the string?

Manikanth Mani
Updated on 22-Jun-2020 06:06:02

115 Views

MySQL INSERT() function performs no insertion if the position of insertion is not within the length of the string. There are certain cases like we pass a negative or 0(zero) value or the value goes beyond the value of a total number of characters in an original string by 2 when we can say that ‘pos’ is not within the length of the string. It can be understood with the help of the following example −ExampleThe query below will perform no insertion because the ‘pos’ is not within the length of string i.e. a negative value.mysql> Select INSERT('Tutorialspoint', -1, 4, '.com'); +--------------------------------------+ ... Read More

In MySQL, how can we insert a substring at the specified position in a string?

Swarali Sree
Updated on 22-Jun-2020 06:04:46

486 Views

We can use a MySQL INSERT() function to insert a substring at the specified position in a string.SyntaxINSERT(original_string, @pos, @len, new_string)Here, original_string is the string in which we want to insert a new string at the place of some specific number of characters.@pos is the position at which the insertion of the new string should start.@len is the number of characters that should delete from the original string. The starting point of the deletion of characters is the value of @pos.New_string is the string we want to insert into the original string.Examplemysql> Select INSERT('MySQL Tutorial', 7, 8, '@Tutorialspoint'); +------------------------------------------------+ | ... Read More

How can we produce a string, other than default binary string, in a given character set by MySQL CHAR() function?

Ankith Reddy
Updated on 22-Jun-2020 06:07:52

51 Views

We can use the keyword USING to produce a string, other than default binary string, in a given character set. Following result set will demonstrate it −mysql> Select CHARSET(CHAR(85 USING utf8)); +------------------------------+ | CHARSET(CHAR(85 USING utf8)) | +------------------------------+ | utf8                         | +------------------------------+ 1 row in set (0.00 sec)The above result set shows that the returned binary string is utf8 because we write utf8 after the keyword USING.mysql> Select CHARSET(CHAR(85 USING latin1)); +--------------------------------+ | CHARSET(CHAR(85 USING latin1)) | +--------------------------------+ | latin1                 ... Read More

How can we check that by default MySQL CHAR() function returns a binary string?

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

76 Views

With the help of CHARSET() function, we can check which string is returned by MySQL CHAR() function. Following result set will demonstrate it − mysql> Select CHARSET(CHAR(85)); +-------------------+ | CHARSET(CHAR(85)) | +-------------------+ | binary | +-------------------+ 1 row in set (0.00 sec)

Advertisements