Found 4219 Articles for MySQLi

How can we MySQL LOAD DATA INFILE statement with ‘FIELDS TERMINATED BY’ option to import data from text file into MySQL table?

Abhinaya
Updated on 06-Feb-2020 05:56:50

848 Views

‘FIELDS TERMINATED BY’ option should be used when the text file which we want to import into MySQL table is having the values which are separated by a comma(, ) or maybe with any other separator like a colon(:), semicolon(;) etc. It can be understood with the help of the following example −ExampleSuppose we are having the following data, separated by a semicolon(;), in the text file ‘A.txt’ which we want to import into a MySQL file −100;Ram;IND;15000 120;Mohan;IND;18000Now with the help of the following query by using the option ‘FIELDS SEPARATED BY ‘we can import the data into MySQL ... Read More

How can we upload the changed value, rather than written in a text file, of column(s) while importing that text file into MySQL table?

Govinda Sai
Updated on 06-Feb-2020 05:58:41

69 Views

Suppose if we want to upload the changed value rather than the value written in a text file then we need to use user variables along with the SET command. It can be understood with the help of the following example −ExampleSuppose we are having the following data in ‘A.txt’ −105, Chum, USA, 11000 106, Danny, AUS, 12000But we want to upload the value of salary after adding 500 to it at the time of importing it without changing the value of salary in a text file then it can be done with the help of the following query by ... Read More

How to insert new string within a string subsequent to removing the characters from the original string by using MySQL function?

Arjun Thakur
Updated on 06-Feb-2020 05:59:31

65 Views

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

How LIKE operator works with comparison operators for matching specific kinds of patterns of a string?

Alankritha Ammu
Updated on 06-Feb-2020 06:00:33

67 Views

We can also use comparison operators in WHERE clause along with LIKE operator to get specific output. It is demonstrated in the following example −ExampleSuppose we want to get the names end with letter ‘v’ from a table but we do not want a specific name say ‘Gaurav’ in the result set then we need to use comparison operator along with LIKE operator as follows −mysql> Select * from student where name like '%v'and name != 'gaurav'; +------+-------+---------+---------+--------------------+ | Id   | Name  | Address | Subject | year_of_admission  | +------+-------+---------+---------+--------------------+ | 2    | Aarav | Mumbai  | History ... Read More

What are the different wildcard characters that can be used with MySQL LIKE operator?

Samual Sam
Updated on 06-Feb-2020 06:05:04

324 Views

As we know that LIKE operator is used along with WILDCARD characters to get the string having specified string. Basically, WILDCARD is the characters that help search data matching complex criteria. Followings are the types of wildcard which can be used in conjunction with LIKE operator % -The PercentageThe ‘%’ wildcard is used to specify a pattern of 0, 1 or more characters. A basic syntax for using % wildcard is as followsSelect Statement…Where column_name LIKE ‘X%’Here, X, is any specified starting pattern such as the single character of more and % matches any number of characters starting from 0.The percentage ... Read More

How MySQL evaluates the blank line between two lines written in the text file while importing that text file into MySQL table?

Ramu Prasad
Updated on 06-Feb-2020 06:07:46

159 Views

Suppose if there is a blank line between two line written in the text file then MySQL evaluates it as the data line while importing that text file into MySQL table. It can be understood with the help of the following example −ExampleSuppose we are having a blank line between two lines in a text file named ‘A.txt’ as follows −105, Chum, USA, 11000 106, Danny, AUS, 12000Now we can write the following query to import the data from text file into MySQL table −mysql> LOAD DATA LOCAL INFILE 'd:\A.txt' INTO table employee10_tbl FIELDS TERMINATED BY ', '; Query OK, ... Read More

Which MySQL function returns a specified number of characters of a string as output?

Ayyan
Updated on 06-Feb-2020 10:52:19

326 Views

MySQL returns a specified number of characters of a string with the help of LEFT() and RIGHT() functions.MySQL LEFT() function will return the specified number of characters from the left of the string.SyntaxLEFT(str, length)Here str is the string from which a number of characters would be returned and the length is an integer value which specifies how many characters to be returned.Examplemysql> Select LEFT('My Name is Ram', 7); +---------------------------+ | LEFT('My Name is Ram', 7) | +---------------------------+ | My Name                   | +---------------------------+ 1 row in set (0.00 sec)MySQL RIGHT() function will ... Read More

How it is possible in MySQL to find a string of specified pattern within another string?

Ankith Reddy
Updated on 04-Feb-2020 06:00:45

67 Views

We can find a string of specified pattern within another string by using LIKE operator along with WILDCARDS.SyntaxLIKE specific_patternSpecific_pattern is the pattern of string we want to find out within another string.ExampleSuppose we have a table named ‘student’ having names of the students and we want to get the details of all those students which are having the pattern of string ‘av’ within their names. It can be done with the help of following MySQL query −mysql> Select * from Student Where Name LIKE '%av%'; +------+--------+---------+-----------+ | Id   | Name   | Address | Subject   | +------+--------+---------+-----------+ ... Read More

What MySQL functions can we use to change the character case of a string?

Kumar Varma
Updated on 04-Feb-2020 06:02:25

102 Views

We can use LCASE() and LOWER() functions for changing the character case of a string to lower case and UCASE() and UPPER() functions for changing the character case of a string to upper case.Examplemysql> Select LCASE('NEW DELHI'); +--------------------+ | LCASE('NEW DELHI') | +--------------------+ | new delhi          | +--------------------+ 1 row in set (0.00 sec) mysql> Select LOWER('NEW DELHI'); +--------------------+ | LOWER('NEW DELHI') | +--------------------+ | new delhi          | +--------------------+ 1 row in set (0.00 sec) mysql> Select UCASE('new delhi'); +--------------------+ | UCASE('new delhi') | +--------------------+ ... Read More

What is the difference between MySQL INSTR() and FIND_IN_SET() functions?

Lakshmi Srinivas
Updated on 04-Feb-2020 06:03:15

309 Views

As we know, both the functions are used to search a string from the arguments provided in them but there are some significant differences between them as followsFIND_IN_SET() function uses the string list that is itself a string containing the substring separated by commas. Whereas, INSTR() function contains a string from which it will find the position of the first occurrence of the substring if present. In case of integers, FIND_IN_SET() is much more suitable than INSTR() function. It can be understood by the following exampleExamplemysql> Select IF(INSTR('10, 11, 12, 13', 2) > 0, 1, 0) As Result; +--------+ | Result ... Read More

Advertisements