SQL¶à¼¶¹ØϵµÄ±íʾ
ÎÒÃÇÒª½¨Á¢¶à¼¶¹Øϵ£¬Ê×ÏÈÐèÒªÁ½¸ö±í.
µÚÒ»¸ö±í±íʾֱÊô½á¹¹£¬±ÈÈç˵ÎÒÃǹ«Ë¾ÓÐÒ»¸ö²¿ÃÅ¡£¶øÕâ¸ö²¿ÃÅÏ»¹ÓÐ3¸öС×飬ÄÇô3¸öС×éÊôÓÚÕâ¸ö²¿ÃÅ.µÚ¶þ¸ö±í±íʾ¶à²ã½á¹¹,¾ÍÏóµÚÒ»±íÀïÃæËù±íʾµÄ£¬ÕâÈý¸öС×éͬʱ»¹ÊôÓÚ¹«Ë¾.¶øÕâ¸ö¹«Ë¾Í¬Ê±ÊôÓÚÕâ3¸öС×éµÄ¸¸¼¶µÄ¸¸¼¶µÄ²¿ÃÅ¡£¼ÙÈçÎÒÃÇÖ»ÓеÚÒ»¸ö±íÀ´±íʾ¹ØϵµÄ»°¡£ÄÇô»áºÜ¸´ÔÓ¡£²¢ÇÒ²éѯÀ§ÄÑ.ËùÒÔÐèÒªÁ½¸ö±íÀ´±íʾËûÃÇÖ®¼äµÄ¹Øϵ.
»òÐíÄãÏÖÔÚ»¹Ã»ÓÐÈÏʶµ½ÎªÊ²Ã´ÐèÒªµÚ¶þ¸ö±í¡£
ÄÇôÏÖÔÚÎÒÀ´¸øÄã˵Ï¡£ÎÒÏÖÔÚÓÐ5¸ö¹«Ë¾£¬²¢ÇÒÿ¸ö¹«Ë¾ÏÂÓÐ5¸ö²¿ÃÅ¡£È»ºóÿ¸ö²¿ÃÅÏÂÓÐ3¸öС×飬¶øÿ¸öС×éÏÂÓÐδ֪Ա¹¤¡£È»ºóÎÒÒª²éѯÆäÖÐÒ»¸ö¹«Ë¾µÄËùÓÐÔ±¹¤¡£ÄÇôÄã²éѯÆðÀ´¾ÍºÜ¸´ÔÓÁË£¬Ê×ÏÈÄãÒª²éѯ³ö¸Ã¹«Ë¾ÏµÄËùÊô²¿ÃÅ£¬È»ºó²éѯËùÊô²¿ÃŵÄËùÓÐС×飬ȻºóÔÙ²éѯËùÊôС×éµÄËùÓÐÔ±¹¤¡£ÕâÑù²ÅÄܲéѯµ½Ô±¹¤¡£
µ«ÊÇ£¬ÊÂÇéÓÀԶûÓÐÕâô¼òµ¥¡£±ÈÈç˵ÎÒÓÐÖ±Êô²¿ÃŵÄÔ±¹¤¡£Ò²¾ÍÊÇ˵£¬Ëû²»ÊôÓÚС×飬ֱ½ÓÊôÓÚÔ±¹¤¡£ÄÇôÄãÔõô°ì£¬Ö»ÄÜunion »òÕßÓÃÁÙʱ±í¡£Äã¿ÉÒÔ˵£¬ÎÒÃÇ¿ÉÒÔ°ÑËûÃÇÏÞÖÆһϣ¬Ô±¹¤²»ÄÜÊôÓÚ²¿ÃÅ£¬µ«ÊÇÕâÊDz»ºÏÀíµÄ¡£ÉõÖÁÓпÉÄÜËûÕâ¸ö¹«Ë¾µ½Ð¡×é½áÊøÁË¡£ÁíÍâÒ»¸ö¹«Ë¾È´²»Ö¹3²ã²¿ÃÅ¡£ÄÇôÄãÔõô°ì¡£²»¿ÉÄÜÿ¸ö¹«Ë¾¶¼¸ã¸öSQLÓï¾ä°É¡£ËùÒÔÕâʱºò¾ÍÐèÒªµÚ¶þ¸ö±íÁË¡£
µÚ¶þ¸ö±í»á±íʾ³öËùÓÐÉϼ¶²¿ÃŵĹØϵ£¬±ÈÈç˵£ºÎÒÓиö¹«Ë¾£¬¹«Ë¾ÏÂÃæÓиöÏúÊÛ²¿£¬ÏúÊÛ²¿ÏÂÃæÓиöÏúÊÛÒ»²¿£¬¶øÏúÊÛÒ»²¿ÏÂÃæÓиöÏúÊÛÒ»×é.ÄÇôÎÒÃÇÒª²éѯÕâ¸öÏúÊÛÒ»×éµÄËùÓи¸¼¶²¿ÃÅ
±¾²¿ÃÅ ¸¸¼¶²¿ÃÅ
ÏúÊÛÒ»×é ÏúÊÛÒ»²¿
ÏúÊÛÒ»×é ÏúÊÛ²¿
ÏúÊÛÒ»×é ôô¹«Ë¾
ÕâÑù¾ÍºÜÇå³þÁË£¬ÒòΪÎÒÃÇÖ»ÐèÒª²é
select ¸¸¼¶²¿ÃÅ from tab where ±¾²¿ÃÅ='ÏúÊÛÒ»×é'
¾ÍÈ«²¿³öÀ´ÁË.¶ø²éѯ¸Ã¹«Ë¾ÏµÄËùÓв¿ÃÅÔò
select ±¾²¿ÃÅ from tab where ¸¸¼¶²¿ÃÅ='ôô¹«Ë¾'
¸Ã¹«Ë¾ÏµÄËùÓв¿ÃžͳöÀ´ÁË£¬È»ºóÎÒÃÇÖ»ÐèÒª inner join һϣ¬²éѯ³ö²¿ÃŵÄËùÓÐÔ±¹¤¡£ºÜ¼òµ¥°É!
ÎÒÃÇÏÖÔÚ˼Ïë˵µÄ²î²»¶àÁË£¬ÏÖÔÚÀ´ËµÒ»ÏÂÔõô¾ßÌåʵÏÖ¡£(ÎÒµÄÄ¿µÄÊDZíʾËùÓеĶ༶¹Øϵ£¬µ«ÊDz»°üº¬ÀúÊ·¼Ç¼µÄ,±ÈÈç˵Ա¹¤´ÓA²¿ÃÅÒƶ¯µ½b²¿ÃÅ,ÎÒµÄÀïÃ涼ûÓÐÓÃÊÂÎï´¦Àí£¬ÎÒÊÇΪÁË·½±ãµ÷Ó㬱ÈÈçÒƶ¯Ô±¹¤°É£¬ÄãÊ×ÏÈupdate ÏÂÔ±¹¤±í£¬È»ºóдÈëÔ±¹¤µÄÀúÊ·¼Ç¼¡£Òâ˼ÊÇÔ±¹¤ÔÚÄĸö²¿ÃÅϹ
Ïà¹ØÎĵµ£º
Ðл»ÁУº
--> Éú³É²âÊÔÊý¾Ý±í: [tb]
IF OBJECT_ID('[tb]') IS NOT NULL
DROP TABLE [tb]
GO
CREATE TABLE [tb] ([a] [int],[b] [int],[c] [int])
INSERT INTO [tb]
SELECT '3','9','5' UNION ALL
SELECT '5','2','7' UNION ALL
SELECT '6','3','8'
--SELECT * from [tb]
-->SQL²éѯÈçÏ ......
select [name] from sysdatabases order by name--µÃµ½Êý¾Ý¿âÖÐËùÓеĿâÃû
select [name] from sysobjects where xtype='U'and [name]<>'dtproperties' order by [name]--µÃµ½Êý¾Ý¿â±íÖеÄÁбí
select [name] from sysobjects where xtype='V' and [name]<>'syssegments' and [name]<>'sysconstraints' ......
ÓÉÓÚ³ÌÐòÐèÒª°ÑSQL SERVER ÀïµÄÊý¾Ýµ¼Èëµ½ACCESSÀï.
¸Õ¿ªÊ¼Ê¹ÓÃDataSetÀ´Ñ»·.
Êý¾ÝÁ¿ÉÙµÄʱºò»¹Ëã¿ÉÒÔÓ¦¸¶µÄ¹ýÀ´.
µ«µ±Êý¾Ý¶àµÄʱºò.
»á±¨´í"λÖôíÎó"
ÔÚÍøÉÏËÑÑ°Ò»·¬.ÕÒµ½Ò»¸ö·½·¨.
ʹÓÃinsert into openrowset
½Ó×Å´íÎóÒ»¸ö½ÓÒ»¸öµÄÀ´..
"²åÈë´íÎó: ÁÐÃû»òËùÌṩֵµÄÊýÄ¿Óë±í¶¨Ò岻ƥÅä¡£"
"δÄÜÕÒµ½ OLE DB Ì ......
/*sqlÖظ´Êý¾Ý´¦Àí£¬ÓÐΨһID£¬formidÓÐÖظ´*/
/*²é³öÖظ´µÄfromid*/
select formid from GaiaSaver_BUG group by formid having count(*)>1
/*ɾ³ýÖظ´formid£¬Ö»ÁôÒ»Ìõ*/
delete from GaiaSaver_BUG where ID not in
(select min(ID) as ID from GaiaSaver_BUG group by for ......
HexString to Binary:
DECLARE @y CHAR(34)
SET @y = '0x499104dc92dd27499da9ad8f56dcb437'
DECLARE @x BINARY(16)
DECLARE @sql NVARCHAR(200)
SET @sql = 'SELECT @x = ' + @y
EXEC sp_executesql
@sql,
N'@x BINARY(16) OUTPUT',
@x OUTPUT
SELECT @x
Binary to HexString:
DECLARE @a VARBINARY(20)
SET ......