MySQL Behavior When Sub-query in UPDATE Returns No Rows

Kumar Varma
Updated on 20-Jun-2020 07:07:27

165 Views

In this case, MySQL will provide a NULL value to the SET clause. Following example will demonstrate it −Examplemysql> Select * from student; +----+---------+-----------+ | Id | Name    | grade     | +----+---------+-----------+ | 1  | Rahul   | Good      | | 2  | Gaurav  | Good      | | 3  | Raman   | Excellent | | 4  | Harshit | Average   | | 5  | Aarav   | Best      | | 6  | Ram     | average   | +----+---------+-----------+ 6 rows in set (0.00 sec) ... Read More

Update Values in One MySQL Table Using Another MySQL Table

Manikanth Mani
Updated on 20-Jun-2020 07:06:58

481 Views

For updating the values in one MySQL table by using the values from another MySQL table, we need to use sub-query as an expression in the SET clause of the UPDATE statement.ExampleIn this example, we have two table ‘student’ and ‘info’. We will update the value of column ‘grade’ of table ‘student’ by using the values from column ‘remarks’ of ‘info’ table.mysql> select * from student; +----+---------+-------+ | Id | Name    | grade | +----+---------+-------+ | 1  | Rahul   | NULL  | | 2  | Gaurav  | NULL  | | 3  | Raman   | NULL  | | ... Read More

Use of ALLOW_INVALID_DATES SQL Mode

Abhinanda Shri
Updated on 20-Jun-2020 07:06:28

3K+ Views

As the name suggests, enabling ALLOW_INVALID_DATES SQL mode will allow us to store invalid dates in the table. The example is given below to understand it −Examplemysql> SET sql_mode = ALLOW_INVALID_DATES; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> Insert Into detail_bday(Name, Birth_Date) values('Sonia', '1993-11-31'); Query OK, 1 row affected (0.09 sec) mysql> Insert Into detail_bday(Name, Birth_Date) values('Ram', '0000-00-00'); Query OK, 1 row affected (0.10 sec) mysql> Select * from detail_bday; +----+---------+------------+ | Sr | Name    | Birth_Date | +----+---------+------------+ | 1  | Saurabh | 1990-05-12 | | 2  | Raman   | 1993-06-11 ... Read More

Use Existing Row Values in UPDATE Statement SET Clause

Swarali Sree
Updated on 20-Jun-2020 07:05:10

191 Views

Existing values of the row can be used to provide new values in the SET clause if that row matches the WHERE clause in an UPDATE statement. Following is the example to demonstrate it.ExampleSuppose we have a table named ‘tender’ as follows −mysql> Select * from tender; +-----------+---------+------+ | tender_id | company | rate | +-----------+---------+------+ | 200       | ABC     | 1000 | | 300       | ABD     | 6000 | | 301       | ABE     | 7000 | | 302       | ABF   ... Read More

MySQL Evaluation of Date and Time Storage in DATE Data Type

Ankitha Reddy
Updated on 20-Jun-2020 07:04:43

138 Views

As we know that the default format for MySQL DATE data type is “YYYY-MM-DD” and in this format, there is no possibility to store the time value. But still, if we store date along with time value in a column having DATE data type then MySQL will show a warning and store only the date value in that column. Following example will exhibit it −Examplemysql> Create table date_time_test(date DATE); Query OK, 0 rows affected (0.44 sec) mysql> Insert into date_time_test(date) values(‘2017-09-09 09:34:21’); Query OK, 1 row affected, 1 warning (0.03 sec) mysql> Select * from date_time_test; +------------+ | ... Read More

Update Multiple Rows with a Single MySQL UPDATE Statement

Jai Janardhan
Updated on 20-Jun-2020 07:03:14

4K+ Views

Column values on multiple rows can be updated in a single UPDATE statement if the condition specified in WHERE clause matches multiple rows. In this case, the SET clause will be applied to all the matched rows.ExampleSuppose we have a table ‘tender’ as follows −mysql> Select * from tender; +-----------+---------+------+ | tender_id | company | rate | +-----------+---------+------+ | 200       | ABC     | 1000 | | 300       | ABD     | 5000 | | 301       | ABE     | 6000 | | 302       ... Read More

Use FROM_UNIXTIME Function with Format String in MySQL

Sravani S
Updated on 20-Jun-2020 06:41:59

209 Views

Suppose if we want the output of FROM_UNIXIME() function in a particular format then we can use date format string or time format string or both in it. Following is the example of using the format string in FROM_UNIXTIME() function −mysql> Select FROM_UNIXTIME(1555033470 '%Y %M %D')AS 'Formatted Output'; +------------------+ | Formatted Output | +------------------+ | 2019 April 12th  | +------------------+ 1 row in set (0.00 sec)In the query above, it is using only date format string.mysql> Select FROM_UNIXTIME(1555033470 '%h:%i:%s')AS 'Formatted Output'; +------------------+ | Formatted Output | +------------------+ | 07:14:30         | +------------------+ 1 row in set (0.00 ... Read More

MySQL UNIX_TIMESTAMP Function Behavior with No Argument

V Jyothi
Updated on 20-Jun-2020 06:41:07

292 Views

In that case, MySQL returns the Unix timestamp of the current date and time. Hence we can say that using no argument is same as using NOW() as an argument to UNIX_TIMESTAMP() function.For example, if we run the query for UNIX_TIMESTAMP() with no value and with NOW() as an argument that MySQL returns the same result.mysql> Select UNIX_TIMESTAMP(); +------------------+ | UNIX_TIMESTAMP() | +------------------+ |       1509405559 | +------------------+ 1 row in set (0.00 sec) mysql> Select UNIX_TIMESTAMP(NOW()); +-----------------------+ | UNIX_TIMESTAMP(NOW()) | +-----------------------+ |            1509405559 | +-----------------------+ 1 row in set (0.00 sec)The ... Read More

Aural Media CSS Properties

Samual Sam
Updated on 20-Jun-2020 06:40:32

95 Views

Aural rendering of documents is mainly used by the visually impaired. The following are the aural media CSS properties −The azimuth property sets, where the sound should come from horizontally.The elevation property sets, where the sound should come from vertically.The cue-after specifies a sound to be played after speaking an element's content to delimit it from other.The cue-before specifies a sound to be played before speaking an element's content to delimit it from other.The cue is a shorthand for setting cue-before and cue-after.The pause-after specifies a pause to be observed after speaking an element's content.The pause-before specifies a pause to be observed ... Read More

Aural Rendering of Documents: Why It Is Necessary

Daniol Thomas
Updated on 20-Jun-2020 06:39:41

192 Views

Aural rendering of documents is mainly used by the visually impaired. Some of the situations in which a document can be accessed by means of aural rendering rather than visual rendering are the following.Learning to readTrainingWeb access in vehiclesHome entertainmentIndustrial documentationMedical documentationWhen using aural properties, the canvas consists of a three-dimensional physical space (sound surrounds) and a temporal space (one may specify sounds before, during, and after other sounds).

Advertisements