Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint
Cover Image
Cover Image
Drag to reposition
Contributed Answers

How can I customize value, instead of NULL, of a row by using MySQL IF() function?

I have some values along with some NULLs stored in MySQL column. But I  want to write something else like N/A or N at the place of NULL. Is it possible to achieve this with the help of MySQL IF() function?
Answered on 21st Feb, 2018, 0 Views

Suppose in our ‘Employee’ table we are having NULL as the value of ‘salary’ column for two employees. The data, shown as follows, is itself not meaningful. , We can avoid displaying NULL in the output by using the IF() function to return ‘N/A’ instead of NULL. ,

How can we get randomly different set of rows or values each time from MySQL table?

I am applying query on MySQL and getting some result set but want to get the different set of records in the result set every time after executing the query.
Answered on 20th Feb, 2018, 0 Views

When we use RAND() function along with both ORDER BY and LIMIT clause in a query, MySQL returns the different set of rows or values each time. To understand it considers a table ‘Employee’ having the following records: , Now, the query below will use RAND() function with both ORDER BY and LIMIT clause in a query return randomly different set of values or rows: , It can be observ.....

What is the resemblance of COALESCE() function with IF-THEN-ELSE statement?

I want to create IF-THEN-ELSE statement which gives the same output as the output of MySQL COALESCE() function. What is the resemblance of COALESCE() function with IF-THEN-ELSE statement?
Answered on 20th Feb, 2018, 0 Views

As we know that COALESCE() function returns first non-NULL value from the list of values. The following IF-THEN-ELSE statement is equivalent to COALESCE() function. ,

How can it be possible to invert a string in MySQL?

With the help of which MySQL function I can upturn a string stored as a value in the column of MySQL table.
Answered on 20th Feb, 2018, 0 Views

MySQL REVERSE() function make it possible to invert a string. Its syntax is as follows: , Here, STR is a string which we want to invert. ,

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

I want to use MySQL FIND_IN_SET () function on the values stored in MySQL table. While using it, I also want to put some conditions on the data. I want to know that how I can use MySQL FIND_IN_SET () function with WHERE clause.
Answered on 20th Feb, 2018, 0 Views

When we use FIND_IN_SET() function in WHERE clause then it searches the search string within the given string as specified in the argument and retrieves all the columns from concerned rows. Following is an example to demonstrate it: In this example, we are getting the columns from ‘Student’ table where the rows have the value of name as ‘Gaurav’. Here the FIND_IN_SET.....

What is the difference between MySQL LENGTH() and CHAR_LENGTH() function?

I want to obtain the number of characters of a specific string and I know I can use two MySQL functions namely MySQL LENGTH() and CHAR_LENGTH() function. But which one is to use when and why?
Answered on 19th Feb, 2018, 0 Views

Both the functions are string functions and return the number of characters present in the string. But they differ in the concept that CHAR_LENGTH() function measures the string length in ‘characters’ whereas LENGTH() function measures the string length in ‘bytes’. In other words, we can say that CHAR_LENGTH() function is multi-byte safe i.e. it ignores whether the c.....

While fetching the data as output, how can I use multiple conditions on same column?

I want to obtain the data, based on more than one condition, stored in a particular column of MySQL table. How can it be possible to apply more than one condition along with WHERE clause?
Answered on 19th Feb, 2018, 0 Views

Followings are the ways in which we can write a query that returns only records that matches multiple conditions on the same column: As we know that MySQL ‘OR’ operator compares two expressions and returns TRUE if either of the expression is TRUE. Following example demonstrate that how we can use ‘OR’ operator for multiple conditions on the same column: , WHERE IN(&h.....

What is MySQL CREATE command? How can we create both database and table with this command?

I want to build a new MySQL database and a new table in it. Is there any data definition command used for building both, database and table?
Answered on 19th Feb, 2018, 0 Views

CREATE command is a DDL command which is used to create a table or a database. The syntax for creating table and database with CREATE command is as follows: The syntax for creating a database: , , In the example above we have created a database named ‘query’. The syntax for creating a table: , , In the example above, we have created a table named ‘Employee’ having tw.....

What is the difference between MySQL PRIMARY KEY and UNIQUE constraint?

How can we distinguish between PRIMARY KEY constraint and UNIQUE constraint? 
Answered on 19th Feb, 2018, 0 Views

The following table will provide us the differences between PRIMARY KEY and UNIQUE constraint: PRIMARY KEYUNIQUE Constraint1. Only one Primary key can be created on a table.1. More than one UNIQUE Constraints can be added to a table.2. Primary key creates clustered index by default.2. UNIQUE Constraint creates a non-clustered index by default.3. We cannot insert null values in the column wh.....

What happens if I will try to drop PRIMARY KEY constraint from the AUTO_INCREMENT column?

I have applied PRIMARY KEY constraint along with AUTO_INCREMENT then how MySQL reacts on trying to delete PRIMARY KEY constraint from that column.
Answered on 16th Feb, 2018, 0 Views

As we know that AUTO_INCREMENT column must have the PRIMARY KEY constraint on it also hence when we will try to drop PRIMARY KEY constraint from the AUTO_INCREMENT column the MySQL returns an error message regarding the incorrect table definition. The example below will demonstrate it: Suppose we have ‘Accounts’ table having the following description:  , It is having a file.....

loader
Advertisements
Contribution

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.