MySQL takes time, datetime field displays problems

Source: Internet
Author: User
Tags one table

This new demand to add folders, engaged in a few days finally understand a little, here and everyone to share the problems I encountered, I hope we can take less detours.


Since our framework uses SSH, some of the SQL statements are not supported, only support HQL, so the first query two tables of some useful fields, one table is user_video_folder another table is user_video the two tables through union all for joint query, I have an article in front of the Union and Union all of the difference, you can go to the view, here is no longer introduced.


The first time through the statement query: The following statement:

SELECT V.folderid, ' folder ' as TYPE, ' error ' as error, ' percentage ' as percentage, ' access ' as Access, ' duration ' as duration, ' up Loadtime ' as Uploadtime, ' Videostatus ' as videostatus,v.userid,v.foldername from User_video_folder v UNION all SELECT p.us Ervideoid, ' video ' as TYPE, Error,percentage,access,p.duration,uploadtime, videostatus,p.userid,p.videoname from User_ Video P

This statement is normal, you can find out the required fields, just at the beginning is hql the varchar field for the Federated query will give an error: Here is the solution link:

http://blog.csdn.net/itzhanghao/article/details/47099881

Now the string type has been resolved, but another problem has arisen. is time and DateTime. It is normal to display the results through a statement query. However, the JSP page does not display properly. In the end, I debugged a lot of scenarios and finally decided to do type conversions when querying:

The first is time conversion: Date_format (p.duration, '%h:%i:%s ')

DateTime conversion, Date_format (Uploadtime, '%y-%m-%d%h:%i:%s ') This solves all the display problems.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MySQL takes time, datetime field displays problems

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.