¡¾Ð¡Ð¡ÎÊÌ⼯½õ13Ö® ¹ØÓÚ·Ö×é¼Ó˳ÐòºÅµÄSQLд·¨¡¿
/*
Ô±í£º
thid other
a 1
a 1
b 0
b 0
b 0
c 2
c 2
Ï£Íû±ä³É£º
thid other
a 1
a 2
b 0
b 1
b 2
c 2
c 3
*/
if OBJECT_ID('tb') is not null
drop table tb
go
create table tb (id varchar(10) ,value int)
insert tb select
'a' , 1 union all select
'a' , 1 union all select
'b' , 0 union all select
'b' , 0 union all select
'b' , 0 union all select
'c' , 2 union all select
'c' , &nb
Ïà¹ØÎĵµ£º
http://www.cnblogs.com/yinzhenzhixin/archive/2009/01/07/1371064.html
ÔÚSQLÓï¾äÖУ¬UNION¹Ø¼ü×Ö¶àÓÃÀ´½«²¢ÁеĶà×é²éѯ½á¹û(±í)ºÏ²¢³ÉÒ»¸ö½á¹û(±í)£¬¼òµ¥ÊµÀýÈçÏ£º
SELECT [Id],[Name],[Comment] from [Product1]
UNION
SELECT [Id],[Name],[Comment] from [Product2]
ÉÏÃæµÄ´úÂë¿ ......
ÔÚiBatis 2.xÖУ¬¿ÉÒÔʹÓÃ$xxxx$Óï·¨ÔÚSQLÖж¨Òå¿É¶¯Ì¬²åÈëµÄSQLÔªËØ¡£¶øÔÚiBatis 3.xÖÐÒѾ·¢ÉúÁ˺ܴó±ä»¯¡£
Ê×ÏÈ£¬Óï·¨±äΪ ${xxxx} ÐÎʽ£»
Æäʵ£¬ÄãҪʹÓõÄSQLÔªËØ±ØÐëÊÇÒ»¸öJava BeanµÄÊôÐÔ£¬Ò²ËµÊÇÊäÈë²ÎÊý±ØÐëΪJava Bean£»ÔÚ˵Ã÷ÎĵµÖÐҲûÓÐ˵Ã÷ÈçºÎÖ±½ÓʹÓÃÒ»¸öStringÀàÐ͵ÄÊäÈë²ÎÊý¡£
ÓÚÊÇ£¬ÎÒÓÃDEBUG·ÖÎöÁËi ......
1¡¢ÔÚÊý¾Ý¿â½¨±íµÄʱºò×Ö¶ÎÖ±½ÓÉèÖÃΪDATETIMEÀàÐÍ£»
2¡¢Ö´ÐвåÈëµÄʱºòʹÓÃÈçÏÂÓï¾ä£º
PreparedStatement pstmt = conn.prepareStatement("insert into guestbook(gst_user,gst_title,gst_content,gst_ip,gst_time) values(?,?,?,?,getdate())");
3¡¢Òª°ÑÈÕÆÚ´ÓÊý¾Ý¿âÖÐÈ¡³ö£¬Ö´ÐÐÈçÏÂÓï¾ä£º
......
select *from student
select student_id from student
select student_id ,student_name from student
select student_id student_name from student ½«student_name ×÷Ϊstudent_idµÄ±ðÃû´¦Àí
È磺 select student_id a from student
select a=student_id from student
´Óstudent±íÖзֱð¼ ......
ÓÃJavaÁ¬½ÓSQL Server2000Êý¾Ý¿âÓжàÖÖ·½·¨£¬ÏÂÃæ½éÉÜÆäÖÐ×î³£ÓõÄÁ½ÖÖ£¨Í¨¹ýJDBCÇý¶¯Á¬½ÓÊý¾Ý¿â£©¡£
1. ͨ¹ýMicrosoftµÄJDBCÇý¶¯Á¬½Ó¡£´ËJDBCÇý¶¯¹²ÓÐÈý¸öÎļþ£¬·Ö±ðÊÇmssqlserver.jar¡¢msutil.jarºÍmsbase.jar£¬¿ÉÒÔµ½Î¢ÈíµÄÍøÕ¾È¥ÏÂÔØ£¨http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A- ......