Found 4219 Articles for MySQLi

How can we import only specific columns from the text file, into MySQL table?

Sravani S
Updated on 04-Feb-2020 06:04:45

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

How can we import the text file, having some line prefixes, into MySQL table?

usharani
Updated on 20-Jun-2020 09:17:27

170 Views

Suppose if we have a line prefix in the text file then with the help of using ‘LINES STARTING BY’ option we can ignore that prefix and import correct data into MySQL table. It can be understood with the help of the following example −ExampleSuppose we are using ‘VALUE’ as the ‘LINE PREFIX’ in the text file as follows −id,         Name,     Country,        Salary VALUE:105,  Chum*,    Marsh, USA,      11000 106,        Danny*,   Harrison, AUS,   12000Now while importing this text file into MySQL table then we ... Read More

How can we import the text file, having data on the same line with a separator, into MySQL table?

varun
Updated on 04-Feb-2020 06:08:24

218 Views

Actually, we can write the data on the same line in the text file by using a separator. In this case, while importing this text file into MySQL table then we must have to use ‘LINES TERMINATED BY’ option. It can be understood with the help of the following example −Suppose we are using ‘|’ as the LINE TERMINATOR symbol in a text file as follows −id, Name, Country, Salary|105, Chum*, Marsh, USA, 11000|106, Danny*, Harrison, AUS, 12000Now while importing this text file into MySQL table then we need to mention ‘LINE TERMINATED BY’ option also in the query as ... Read More

How can we use MySQL INSTR() function with WHERE clause?

Chandu yadav
Updated on 04-Feb-2020 06:10:29

689 Views

When we use INSTR() function with MySQL WHERE clause, we need to provide column name of the table as the first argument and the substring as second argument along with a comparison operator. Following is an example using ‘Student’ table to demonstrate it −ExampleSuppose we have the following values in ‘Student’ table −mysql> Select * from Student; +------+---------+---------+-----------+ | Id   | Name    | Address | Subject   | +------+---------+---------+-----------+ | 1    | Gaurav  | Delhi   | Computers | | 2    | Aarav   | Mumbai  | History   | | 15   | Harshit | ... Read More

How MySQL evaluates if we use any other escape character rather that back-slash () in a text file while importing the data from text file to MySQL table?

Srinivas Gorla
Updated on 04-Feb-2020 06:12:01

228 Views

Back-slash(\) is the by default escape character for the MySQL and when we use it in the text file then we do not need to mention it in the query while importing the data from text file to table. But if we use any other character as escape character then it must be mentioned by using ESCAPED BY option in the query while importing the text file into a table. It can be understood with the help of the following example −Suppose we are using star symbol (‘* ‘) as the escape character in a text file as follows −id, ... Read More

What is the use of escape character () in text file while importing the data from text file to MySQL table?

Prabhas
Updated on 04-Feb-2020 06:14:32

291 Views

Use of escape character (\) would become very essential when we want to insert a comma or any other character between the values of a filed. It can be understood with the help of an example. Suppose we want to import the data from a text file named A.txt, having the following data, into a MySQL table −id,   Name,    Country,       Salary 105,  Chum,    Marsh, USA,     11000 106,  Danny,   Harrison, AUS,  12000Here, we can see that the filed name has two values first name, last name separated by a comma. Now, the ... Read More

What is the use of MySQL BINARY keyword while performing string comparison?

karthikeya Boyini
Updated on 04-Feb-2020 05:46:37

738 Views

When MySQL performs string comparison then it is not case-sensitive but with the help of BINARY keyword, MySQL can perform case-sensitive string comparison. It is because BINARY keyword instructs MySQL to compare the characters in the string using their underlying ASCII values rather than just their letters. It can be illustrated with the following example from table ‘Student_info’ having the following data −mysql> Select * from student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101  | YashPal | Amritsar   | History    | | 105  | Gaurav  | Chandigarh | ... Read More

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

Arjun Thakur
Updated on 04-Feb-2020 05:47:47

451 Views

When we use LOCATE() function with MySQL WHERE clause, we need to provide the substring as first argument and column name of the table as the second argument along with a comparison operator. Following is an example using ‘Student’ table to demonstrate it −ExampleSuppose we have the following values in ‘Student’ table −mysql> Select * from Student; +------+---------+---------+-----------+ | Id   | Name    | Address | Subject   | +------+---------+---------+-----------+ | 1    | Gaurav  | Delhi   | Computers | | 2    | Aarav   | Mumbai  | History   | | 15   | Harshit ... Read More

How is it possible in MySQL to find the location of the first occurrence of a substring in a string?

Anjana
Updated on 04-Feb-2020 05:50:33

307 Views

MySQL LOCATE() function makes it possible to find the location of the first occurrence of a substring in a string. Following is the syntax of using it −SyntaxLOCATE(Substring, String)In this function, Substring is the string whose position of occurrence needs to find and the string is a string from which the occurrence of substring needs to be searched.We must have to pass both the strings (i.e. substring, which is to be searched and the string, from which substring is to be searched) as arguments of the LOCATE() function.Examplemysql> Select LOCATE('Good', 'RAM IS A GOOD BOY')As Result; +--------+ | Result | ... Read More

How can we import data from a text file having names of the columns in first row?

Abhinaya
Updated on 04-Feb-2020 05:52:05

357 Views

Sometimes, the input text file has the names of the columns in the first row and to import data from such kind of text file to MySQL table we need to use ‘IGNORE ROWS’ option. To illustrate it we are using the following example −ExampleFollowings are the comma separated values in A.txt file −Id, Name, Country, Salary 100, ”Ram”, ”INDIA”, 25000 101, ”Mohan”, ”INDIA”, 28000We want to import this data into the following file named employee3_tbl −mysql> Create table employee3_tbl(Id Int, Name Varchar(20), Country Varchar(20), Salary Int); Query OK, 0 rows affected (0.1 sec)Now, the transfer of data from a ... Read More

Advertisements