Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Insert into select SQL¿çÊý¾Ý¿â¸´ÖÆÊý¾Ý


ת×Ô£ºÃ÷Ò¹ÐÇ¿Õ -- Insert select ´øÑ¡Ôñ¸´ÖÆÒ»ÕÅ±íµ½ÁíÒ»Õűí
ʹÓÃSELECT INTO ºÍ INSERT INTO SELECT ±í¸´ÖÆÓï¾äÁË¡£
1.INSERT INTO SELECTÓï¾ä
Óï¾äÐÎʽΪ£ºInsert into Table2(field1,field2,...) select value1,value2,... from Table1 [where column =value]
[]Ϊ¿ÉÑ¡ÄÚÈÝ
ÒªÇóÄ¿±ê±íTable2±ØÐë´æÔÚ£¬ÓÉÓÚÄ¿±ê±íTable2ÒѾ­´æÔÚ£¬ËùÒÔÎÒÃdzýÁ˲åÈëÔ´±íTable1µÄ×Ö¶ÎÍ⣬»¹¿ÉÒÔ²åÈë³£Á¿¡£Ê¾ÀýÈçÏ£º
insert into tjjrmx(yybh,xh,tjxmbh,jg,sfyx,zhxmbh,tjksbh,jcrq,jcys,ts,ckfw,disporder)
      select '24',xh,tjxmbh,jg,sfyx,zhxmbh,tjksbh,jcrq,jcys,ts,ckfw,disporder from tjjrmx where yybh = 5
2.SELECT INTO fromÓï¾ä
      Óï¾äÐÎʽΪ£ºSELECT vale1, value2 into Table2 from Table1
      ÒªÇóÄ¿±ê±íTable2²»´æÔÚ£¬ÒòΪÔÚ²åÈëʱ»á×Ô¶¯´´½¨±íTable2£¬²¢½«Table1ÖÐÖ¸¶¨×Ö¶ÎÊý¾Ý¸´ÖƵ½Table2ÖС£Ê¾ÀýÈçÏ£º
3.´ÓÒ»¸öÊý¾Ý¿âµ½ÁíÒ»¸öÊý¾Ý¿â
        Óï¾äÐÎʽΪ£ºinsert into Êý¾Ý¿âÃû.¿ò¼ÜÃû.±íÃû(ÁÐÃû) select (ÁÐÃû) from Êý¾Ý¿âÃû.¿ò¼ÜÃû.±íÃû where Ìõ¼þ
        ÀýÈ磺insert into MyEmp.dbo.tjdjb(yybh)
select yybh
from MyCmd.dbo.tjdjb where djrq='2009-10-15' and yybh = '11'
select a,c INTO Table2 from Table1


Ïà¹ØÎĵµ£º

SQL SERVER ÓëACCESS¡¢EXCELµÄÊý¾Ýת»»

ÊìϤSQL SERVER 2000µÄÊý¾Ý¿â¹ÜÀíÔ±¶¼ÖªµÀ£¬ÆäDTS¿ÉÒÔ½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬Æäʵ£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃTransact-SQLÓï¾ä½øÐе¼Èëµ¼³ö²Ù×÷¡£ÔÚTransact-SQLÓï¾äÖУ¬ÎÒÃÇÖ÷ҪʹÓÃOpenDataSourceº¯Êý¡¢OPENROWSET º¯Êý£¬¹ØÓÚº¯ÊýµÄÏêϸ˵Ã÷£¬Çë²Î¿¼SQLÁª»ú°ïÖú¡£ÀûÓÃÏÂÊö·½·¨£¬¿ÉÒÔÊ®·ÖÈÝÒ×µØʵÏÖSQL SERVER¡¢ACCESS¡¢EXCELÊý¾Ýת»»£ ......

JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,Oracle

import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
  
public static void main(String[] args)throws Exception {
  
   Connection conn=null;
  
       //====Á¬½ÓACCESSÊý¾Ý¿â ......

[ÊÕ£] ÓÃsqlite Ö´Ðбê×¼ sql Óï·¨

http://www.umgr.com/blog/PostView.aspx?bpId=36294
 1. Ö´ÐÐsqlÓï¾ä
int sqlite3_exec(sqlite3*£¬ const char *sql£¬ sqlite3_callbacksql Óï·¨
£¬ void *£¬  char **errmsg );
Õâ¾ÍÊÇÖ´ÐÐÒ»Ìõ sql Óï¾äµÄº¯Êý¡£
µÚ1¸ö²ÎÊý²»ÔÙ˵ÁË£¬ÊÇÇ°Ãæopenº¯ÊýµÃµ½µÄÖ¸Õ롣˵ÁËÊǹؼüÊý¾Ý½á¹¹¡£
µÚ2¸ö²ÎÊýconst char ......

sql¸ù¾Ý»ù±íÅúÁ¿ÐÞ¸Ä×Ó±í

update ×Ó±íÃû 
set ÒªÐ޸ĵÄ×Ó±í×Ö¶Î=b.»ù±íÖÐÒªÌí¼Óµ½×Ó±íÖеÄ×Ö¶Î
from ×Ó±íÃû,(select ×Ó±íÃû.ÒªÐ޸ĵÄ×Ó±í×Ö¶Î,»ù±íÃû.Òª²Î¼Ó±È½ÏµÄ×ֶΠfrom ×Ó±íÃû,»ù±íÃû where »ù±íÃû.Òª²Î¼Ó±È½ÏµÄ×Ö¶Î=×Ó±íÃû.×Ó±íÖÐÒª²Î¼Ó±È½ÏµÄ×Ö¶Î)as b
where b.»ù±íÖÐÒª²Î¼Ó±È½ÏµÄ×Ö¶Î=×Ó±íÒª²Î¼Ó±È½ÏµÄ×Ö¶Î
Èç
update Ä£°å ......

SQLÓï¾äʾÀý

 --²éѯÊý¾Ý
SELECT *
from main_table;
--Ìí¼ÓÊôÐÔ
ALTER TABLE main_table
ADD AcctStop_Time SMALLDATETIME NULL;
--²åÈëÐÂÊý¾Ý
INSERT INTO main_table(Digital_ID, Letter_ID, User_Password, On_Line, IP, AcctStop_Time, FriendTable_UpdaeTime)
VALUES(10000000 + IDENT_CURRENT('main_table') + IDEN ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ