I was asked the other day by someone about some software that could Join/Merge two tables (fields and rows). I thought it’d be pretty easy with some MySQL query but couldn’t find any solution. Then I turned to google in search of any software or any other source that could help me out… but still […]
Category: MySQL
Fetch Fields (of one row) from a MySQL Table
I was sick and tired of writing small queries where I had to retrieve one or few or even all records of one row against an id. E.g. when I had a userid and I had to fetch firstname, lastname and/or email against that id, I had to write a query each time and then […]
Calculating Age from Date of Birth in MySQL
I was doing some experiments the other day with MySQL and wrote some interesting queries to calculate age using MySQL. Here you go. SELECT DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),”1978-03-28″)), ‘%Y’)+0 AS age 1:- DATEDIFF(NOW(),”1978-03-28″) This function DATEDIFF() returns difference of two dates in days, e.g. DATEDIFF(“1978-04-28”, “1978-03-28”) will return 31 days. So by using NOW() i.e. current date, in […]