- 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
70 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
70 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
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
325 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
163 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
330 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
71 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
103 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
314 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
1K+ Views
Suppose if we have the values for some specific columns in the text file and MySQL table, in which we want to import the data, is having an extra column(s) then by mentioning the names of the columns in the query we can upload the values of those specific columns only. It can be understood with the help of the following example −ExampleSuppose we are having the values of columns ‘id’, ‘Name’ and ‘Salary’ only in the text file as follows −105, Chum, 11000 106, Danny, 12000Now while importing this text file into MySQL table then we need to mention ... Read More