Found 4381 Articles for MySQL

What kind of settings can we do to a text file by query while exporting the values from MySQL table into a text file?

vanithasree
Updated on 20-Jun-2020 09:26:54

149 Views

While exporting the data from MySQL table to a text file we can use ‘FIELDS TERMINATED BY’, ‘ENCLOSED BY’, ‘LINES TERMINATED BY’ and other options too to put the values of fields in different settings of the text file. It can be illustrated with the help of the following example −ExampleSuppose we are having following data from table ‘Student_info’ −mysql> Select * from Student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101  | YashPal | Amritsar   | History    | | 105  | Gaurav  | Chandigarh | Literature | | ... Read More

Why we cannot use comparison operator(=) for getting the rows with NULL from a table?

Ankith Reddy
Updated on 06-Feb-2020 06:41:12

81 Views

We cannot use = (comparison operator) because we know that NULL is not a value. If we want to get the rows with NULL from a table then we need to use IS NULL operator in MySQL query. Following example using the data from ‘employee’ table will exhibit it −Examplemysql> Select * from Employee WHERE Salary IS NULL; +----+-------+--------+ | ID | Name  | Salary | +----+-------+--------+ | 7  | Aryan | NULL   | | 8  | Vinay | NULL   | +----+-------+--------+ 2 rows in set (0.00 sec)The query above use IS NULL operator and produces ... Read More

How can we export some field(s) from MySQL table into a text file?

Abhinanda Shri
Updated on 20-Jun-2020 09:23:46

916 Views

It can be done by providing the column(s) names in the SELECT … INTO OUTFILE statement while exporting the data from MySQL table into a file. We are illustrating it with the help of the following example −ExampleSuppose we are having following data from table ‘Student_info’ −mysql> Select * from Student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101  | YashPal | Amritsar   | History    | | 105  | Gaurav  | Chandigarh | Literature | | 125  | Raman   | Shimla     | Computers  | | 130 ... Read More

How can we export all the data from MySQL table into a text file?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

806 Views

It can be done with the help of SELECT … INTO OUTFILE statement. We are illustrating it with the help of the following example − Example Suppose we are having following data from table ‘Student_info’: mysql> Select * from Student_info; +------+---------+------------+------------+ | id | Name | Address | Subject | +------+---------+------------+------------+ | 101 | YashPal | Amritsar | History | | 105 | Gaurav | Chandigarh | Literature | | 125 | Raman | Shimla ... Read More

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

1K+ 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

119 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

123 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

134 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

422 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

265 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

Advertisements