MySQL Articles

Page 118 of 355

How can I use another MySQL function/s with REPEAT() function?

Chandu yadav
Chandu yadav
Updated on 07-Feb-2020 163 Views

Suppose if we want to make the output of REPEAT() function more readable then we can use another function/s with it. For example, if we want to add space or some other character between the repeated values then we can use CONCAT() function.Examplemysql> Select REPEAT(CONCAT(' *', Subject, '* '), 3)AS Subject_repetition from student; +-----------------------------------------+ | Subject_repetition                      | +-----------------------------------------+ | *Computers* *Computers* *Computers*     | | *History* *History* *History*           | | *Commerce* *Commerce* *Commerce*        | | *Computers* *Computers* *Computers*     | ...

Read More

How to repeat the values stored in a data column of MySQL table?

Akshaya Akki
Akshaya Akki
Updated on 07-Feb-2020 289 Views

For repeating the values stored in a data column of MySQL table, the name of the column must be passed as the first argument of REPEAT() function. The data from ‘Student’ table is used to demonstrate it:Examplemysql> Select REPEAT(Name,3)AS Name from student; +-----------------------+ | Name                  | +-----------------------+ | GauravGauravGaurav    | | AaravAaravAarav       | | HarshitHarshitHarshit | | GauravGauravGaurav    | | YashrajYashrajYashraj | +-----------------------+ 5 rows in set (0.00 sec)

Read More

What MySQL returns if the argument of QUOTE() function is NULL?

Ankith Reddy
Ankith Reddy
Updated on 07-Feb-2020 187 Views

MySQL returns NULL if the argument of QUOTE() function is NULL.Examplemysql> Select QUOTE(NULL); +-------------+ | QUOTE(NULL) | +-------------+ | NULL         +-------------+ 1 row in set (0.00 sec) mysql> Select Name, QUOTE(NULL) from student where id = 1; +--------+-------------+ | Name   | QUOTE(NULL) | +--------+-------------+ | Gaurav | NULL        | +--------+-------------+ 1 row in set (0.08 sec)

Read More

What are the different wildcard characters which can be used with NOT LIKE operator?

Jai Janardhan
Jai Janardhan
Updated on 07-Feb-2020 243 Views

As we know that NOT LIKE operator is used along with WILDCARD characters for not getting 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 NOT LIKE operator:% - The PercentageThe ‘%’ wildcard is used to specify a pattern of 0, 1 or more characters. A basic syntax for using % wildcard with NOT LIKE operator is as follows:Select Statement…Where column_name NOT LIKE ‘X%’Here X is any specified starting pattern such as the single character of more and % matches ...

Read More

In MySQL, how can we check whether a string of a specified pattern is not present within another string?

Ankith Reddy
Ankith Reddy
Updated on 07-Feb-2020 195 Views

We can check whether a string of specified pattern is not present within another string by using NOT LIKE operator along with wildcard characters.SyntaxNOT LIKE specific_patternSpecific_pattern is the pattern of string we do not 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 not having a pattern of string ‘av’ within their names. It can be done with the help of following MySQL query:mysql> Select * from Student WHERE name NOT LIKE '%av%'; +------+---------+---------+----------+--------------------+ | Id   ...

Read More

How can we take a backup of a particular table from a database by using mysqldump client program?

Jennifer Nicholas
Jennifer Nicholas
Updated on 07-Feb-2020 300 Views

By using mysql dump client program we can take the backup of a particular table from the databases into a file having the extension ‘.sql’. It can be understood with the help of the following example −ExampleIn this example, with the help of mysql dump client program, we are taking the backup of a table named ‘student_info’ from ‘query’ database in a file named ‘student_info.sql’. The following command will do this:C:\mysql\bin>mysqldump -u root query student_info > student_info.sqlThe above command will create a file named student_info.sql which has the dump information of a file named ‘student_info’ from database named ‘query’.

Read More

What are the similarities and differences between MySQL ORD() and ASCII() functions?

Monica Mona
Monica Mona
Updated on 07-Feb-2020 454 Views

MySQL ORD() function returns the code for the leftmost character if that character is a multi-byte i.e. sequence of one or more bytes, with the help of the following formula(1st bytecode) + (2nd bytecode * 256) + (3rd bytecode * 256^2)On the other hand, ASCII() function returns the ASCII value of the leftmost character of a given string.The difference between them lies on the point that whether the leftmost character is a multi-byte character or not. If it is not a multi-byte character then both ORD() and ASCII() functions return similar results. Following example will demonstrate it.mysql> Select ORD('Tutorialspoint'); +-----------------------+ ...

Read More

How can I use MySQL OCTET_LENGTH() function to count the number of characters stored in a data column?

Chandu yadav
Chandu yadav
Updated on 07-Feb-2020 155 Views

We need to pass the column name as the argument of OCTET_LENGTH() function to count the number of characters stored in a data column. It displays the number of characters when referenced in SELECT clause. It can also be used as comparison value to decide whether or not the row should returned by using it in WHERE clause. The contents of ‘Student’ table are used to demonstrate it −mysql> Select Name, OCTET_LENGTH(Name)As 'Str_Length' from Student; +---------+------------+ | Name    | Str_Length | +---------+------------+ | Gaurav  | 6          | | Aarav   | 5       ...

Read More

How can we take a backup of all the databases by using mysqldump client program?

Nitya Raut
Nitya Raut
Updated on 07-Feb-2020 266 Views

By using mysql dump client program we can take the backup of all the databases into a file having the extension ‘.sql’. It can be understood with the help of the following example −ExampleIn this example, with the help of mysql dump client program, we are taking the backup all the databases in a file named ‘alldatabases.sql’. The following command will do this −C:\mysql\bin>mysqldump -u root --all-databases > alldatabases.sqlThe above command will create a file named alldatabases.sql which has the dump information of all the databases.

Read More

How can I restore a database dumped by mysqldump?

Giri Raju
Giri Raju
Updated on 07-Feb-2020 284 Views

Suppose if we have dumped the whole database and now want to restore it then we can do it with the following example −C:\mysql\bin>mysql -u root query < tutorials.sqlWith the help of above query, we are restoring the dumped database named ‘tutorials’, in the file tutorials.sql, into other database named ‘query’. It means that the tables of database ‘tutorials’ would be restored in a database named ‘query’.

Read More
Showing 1171–1180 of 3,547 articles
« Prev 1 116 117 118 119 120 355 Next »
Advertisements