SQLÖÐ CAST Óë CONVERTת»¯º¯ÊýµÄÓ÷¨
½«Ä³ÖÖÊý¾ÝÀàÐ͵ıí´ïʽÏÔʽת»»ÎªÁíÒ»ÖÖÊý¾ÝÀàÐÍ¡£CAST ºÍ CONVERT ÌṩÏàËƵŦÄÜ¡£
Óï·¨
ʹÓà CAST£º
CAST ( expression AS data_type )
ʹÓà CONVERT£º
CONVERT (data_type[(length)], expression [, style])
²ÎÊý
expression
ÊÇÈκÎÓÐЧµÄ Microsoft® SQL Server™ ±í´ïʽ¡£Óйظü¶àÐÅÏ¢£¬Çë²Î¼û±í´ïʽ¡£
data_type
Ä¿±êϵͳËùÌṩµÄÊý¾ÝÀàÐÍ£¬°üÀ¨ bigint ºÍ sql_variant¡£²»ÄÜʹÓÃÓû§¶¨ÒåµÄÊý¾ÝÀàÐÍ¡£ÓйؿÉÓõÄÊý¾ÝÀàÐ͵ĸü¶àÐÅÏ¢£¬Çë²Î¼ûÊý¾ÝÀàÐÍ¡£
length
nchar¡¢nvarchar¡¢char¡¢varchar¡¢binary »ò varbinary Êý¾ÝÀàÐ͵ĿÉÑ¡²ÎÊý¡£
style
˵Ã÷:
´ËÑùʽһ°ãÔÚʱ¼äÀàÐÍ(datetime,smalldatetime)Óë×Ö·û´®ÀàÐÍ(nchar,nvarchar,char,varchar)
Ï໥ת»»µÄʱºò²ÅÓõ½.
Àý×Ó:
SELECT CONVERT(varchar(30),getdate(),101) now
½á¹ûΪ
now
---------------------------------------
09/15/2001
/////////////////////////////////////////////////////////////////////////////////////
styleÊý×ÖÔÚת»»Ê±¼äʱµÄº¬ÒåÈçÏÂ
-------------------------------------------------------------------------------------------------
Style(2λ±íʾÄê·Ý) | Style(4λ±íʾÄê·Ý) | ÊäÈëÊä³ö¸ñʽ
-------------------------------------------------------------------------------------------------
- | 0 or 100 | mon dd yyyy hh:miAM(»òPM)
-------------------------------------------------------------------------------------------------
1 | 101 | mm/dd/yy
-------------------------------------------------------------------------------------------------
2 | 102 | yy-mm-dd
-------------------------------------------------------------------------------------------------
3 | 103 | dd/mm/yy
-------------------------------------------------------------------------------------------------
4 | 104 | dd-mm-yy
-------------------------------------------------------------------------------------------------
5 | 105 | dd-mm-yy
-------------------------------------------------------------------------------------------------
6 | 106 | dd mon yy
------------------------------------------------------------------------------
Ïà¹ØÎĵµ£º
@SuppressWarnings("unchecked")
public List<ZxFunction> selectFunctionParentByUserId(final int userId) {
try {
final String sql = "select * from zx_function ......
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Default" value="Default" />
</appSettings>
<connectionStrings>
<add name="Default" connectionString="Data Source=192.168.1.197;User ID ......
1¡¢ÎļþºÍÎļþ×éµÄº¬ÒåÓë¹Øϵ
ÿ¸öÊý¾Ý¿âÓÐÒ»¸öÖ÷Êý¾ÝÎļþ.ºÍÈô¸É¸ö´ÓÎļþ¡£ÎļþÊÇÊý¾Ý¿âµÄÎïÀíÌåÏÖ¡£ Îļþ×é¿ÉÒÔ°üÀ¨·Ö²¼ÔÚ¶à¸öÂß¼·ÖÇøµÄÎļþ£¬ÊµÏÖ¸ºÔØƽºâ¡£Îļþ×éÔÊÐí¶ÔÎļþ½øÐзÖ×飬ÒÔ±ãÓÚ¹ÜÀíºÍÊý¾ÝµÄ·ÖÅ䣯·ÅÖá£ÀýÈ磬¿ÉÒÔ·Ö±ðÔÚÈý¸öÓ²ÅÌÇý¶¯Æ÷ÉÏ´´½¨Èý¸öÎļþ£¨Data1.ndf¡¢Data2.ndf ºÍ Data3.ndf£©£¬²¢½«ÕâÈý¸ ......
JOINÓÅ»¯
MySQLÖÐjoinµÄʵÏÖ²ÉÓõÄÊÇNested Loop JoinËã·¨¡£Í¨¹ýÇý¶¯±íµÄ½á¹û¼¯×÷Ϊѻ·»ù´¡Êý¾Ý£¬È»ºó½«¸Ã½á¹û¼¯ÖеÄÊý¾Ý×÷Ϊ¹ýÂË
Ìõ¼þÒ»ÌõÌõµÄµ½ÏÂÒ»¸ö±íÖвéѯÊý¾Ý£¬×îºóºÏ²¢½á¹û£¬Èç¹û´æÔÚºóÐø±í£¬¹ý³ÌÒ²Èç´Ë¡£
¾¡Á¿¼õÉÙjoinÓï¾äÖÐnested loopÑ»·µÄ´ÎÊý¡£×îÓÐЧµÄ·½·¨ÊÇÈÃÇý¶¯±íµÄ½á¹û¼¯¾¡¿ÉÄܵÄС
ÓÅÏÈÓÅ»¯nested ......