Tags
Asked 2 years ago
29 Jul 2021
Views 258
Domenic

Domenic posted

What are Built-In function in MySQL with example ?


i am studying MySQL , so i want to know which Built-In Function i can use in daily usage , Please show me some example of MySQL Built-In Function ?
What are Built-In function in MySQL with example ?
jessica

jessica
answered Aug 19 '21 00:00

The function can be used to do some specific job in MySQL, Following are the Built-In function


md5() - is used to hash the string
CONCAT() - is used to concat two or more string , for example SELECT CONCAT('A','B','A','B') return ABAB
ROUND() - is used to round the value . for example SELECT ROUND(120.334) which return 120 is round of the 120.334
CURTIME() - is used to return the current time , for example SELECT CURTIME() which return time like this 15:47:26
DATABASE() - is used to get the current database name , for example SELECT DATABASE() which return current selected database name.
DATEDIFF() - is used to give the difference between two date , for example SELECT DATEDIFF('2021-08-12','2021-08-02') which return 10
david

david
answered Aug 19 '21 00:00

md5() is a function that can be used to hash the string, it can be used to store some sensitive information like password
md5() function is one-way encryption because it can't be recovered from hash to original text
for example :

select md5('123456')


it will output :
e10adc3949ba59abbe56e057f20f883e which is md5 hash of "123456" so now there is no function that can convert md5 hash to original text means we cant e10adc3949ba59abbe56e057f20f883e convert into 123456

so suppose you are using md5() for hashing password, then how to check the password in future
1. store the hash to the database at registration time
2. now at login time, convert the given password to hash to check with the stored hash


select * from user where md5(123456)=user.password


if given password is correct than it return user
Post Answer