MySQLREVERSE()
函数可以使用列名作为参数来反转其值。如果我们要应用某些条件,则可以将其与WHERE子句一起使用,如下所示:
mysql> Select Name, REVERSE(Name) from Student; +---------+---------------+ | Name | REVERSE(Name) | +---------+---------------+ | Aarav | varaA | | Gaurav | varuaG | | Gaurav | varuaG | | Harshit | tihsraH | | Yashraj | jarhsaY | +---------+---------------+ 5 rows in set (0.00 sec)
上面的查询将“学生”表中“名称”列的值取反。现在,下面的查询将使用REPLACE()
带有WHERE子句的函数:
mysql> Select Name, REVERSE(Name) from Student WHERE Subject = 'History'; +-------+---------------+ | Name | REVERSE(Name) | +-------+---------------+ | Aarav | varaA | +-------+---------------+ 1 row in set (0.00 sec)