SQL SERVER 2005 ¸ß¼¶²éѯ£¨×Ó²éѯ²éѯ£©
--SQL¸ß¼¶³ÌÐòÉè¼Æ£º×Ó²éѯ
use AdventureWorks
GO
SELECT DISTINCT EmployeeID from HumanResources.JobCandidate WHERE EmployeeID IS NOT NULL;
SELECT e.EmployeeID,FirstName,LastName
from HumanResources.Employee e
INNER JOIN Person.Contact c
ON e.ContactID = c.ContactID
WHERE e.EmployeeID IN (SELECT DISTINCT EmployeeID from HumanResources.JobCandidate
WHERE EmployeeID IS NOT NULL)
SELECT DISTINCT EmployeeID from HumanResources.JobCandidate WHERE EmployeeID IS NOT NULL
SELECT e.EmployeeID,FirstName,LastName
from HumanResources.Employee e
INNER JOIN Person.Contact c
ON e.ContactID = c.ContactID
WHERE e.EmployeeID NOT IN (
SELECT DISTINCT EmployeeID
from HumanResources.JobCandidate
WHERE EmployeeID IS NOT NULL
)
SELECT CustomerID,MIN((OrderDate)) AS OrderDate
INTO #MinOrderDates
from Sales.SalesOrderHeader
GROUP BY CustomerID
ORDER BY CustomerID
SELECT o.CustomerID,o.SalesOrderID,o.OrderDate
from Sales.SalesOrderHeader o
inner join #MinOrderDates t
on o.CustomerID = t.CustomerID
and o.OrderDate = t.OrderDate
order by o.CustomerID
DROP TABLE #MinOrderHeaders
SELECT O1.CustomerID,o1.SalesOrderID,o1.OrderDate
from Sales.SalesOrderHeader o1
WHERE o1.OrderDate = (SELECT MIN(o2.OrderDate)
from Sales.SalesOrderHeader o2
WHERE O2.CustomerID = o1.CustomerID)
ORDER BY CustomerID
SELECT c.LastName,ISNULL(CAST((SELECT MIN(OrderDate) from Sales.SalesOrderHeader o
WHERE o.ContactID = c.ContactID) AS VARCHAR),'NEVER RECORD') AS "Order Date"
from Person.Contact c
SELECT e.EmployeeID,FirstName,LastName
from HumanResources.Employee e
INNER JOIN Person.Contact c
ON e.ContactID = c.ContactID
WHERE EXISTS(SELECT DISTI
Ïà¹ØÎĵµ£º
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ÅúÁ¿ÐÞ¸Ä×Ö¶ÎÄÚÈݵÄÓï¾ä
1¡¢Ã»ÊÔ¹ý£¬ÍøÉÏËÑË÷µÄ
ÒýÓÃ
update '±íÃû' set ÒªÐÞ¸Ä×Ö¶ÎÃû = replace (ÒªÐÞ¸Ä×Ö¶ÎÃû,'±»Ìæ»»µÄÌض¨×Ö·û','Ìæ»»³ÉµÄ×Ö·û')
2¡¢×Ô¼º°´ÕÕÒ»¸öÒ»¸öÐÞ¸ÄÊÇ¿´Êý¾Ý±í×ܽáµÄ
ÀýÈçżÐÞ¸Ä×Ô¼º²©¿Íboblog_replies±íÖеÄadminrepidºÍadminreplier×Ö¶ÎÖµ£º
UPDATE `xxx`.`boblog_ ......
£¨18£©ÓÃEXISTSÌæ»»DISTINCT£º
µ±Ìá½»Ò»¸ö°üº¬Ò»¶Ô¶à±íÐÅÏ¢(±ÈÈ粿ÃűíºÍ¹ÍÔ±±í)µÄ²éѯʱ,±ÜÃâÔÚSELECT×Ó¾äÖÐʹÓÃDISTINCT¡£Ò»°ã¿ÉÒÔ¿¼ÂÇÓÃEXISTÌæ»», EXISTS ʹ²éѯ¸üΪѸËÙ,ÒòΪRDBMSºËÐÄÄ£¿é½«ÔÚ×Ó²éѯµÄÌõ¼þÒ»µ©Âú×ãºó,Á¢¿Ì·µ»Ø½á¹û¡£Àý×Ó£º
(µÍЧ):
SELECT DISTINCT DEPT_NO,DEPT_NAME  ......
l INNER JOIN
ÄÚÁ¬½ÓÊÇ×î³£¼ûµÄÒ»ÖÖÁ¬½Ó£¬ËüÒ³±»³ÆΪÆÕͨÁ¬½Ó£¬¶øE.FCodd×îÔç³Æ֮Ϊ×ÔÈ»Á¬½Ó¡£
ÏÂÃæÊÇANSI SQL£92±ê×¼
select * from t_institution i
inner join t_teller t
on i.inst_no = t.inst_no //˵Á½¸ö±íÖ®¼äµÄ¹ØϵÓÃON
where i.inst_no = "5801"
ÆäÖÐinner¿ÉÒÔÊ¡Â ......
ÒýÓÃ:http://blog.csdn.net/wizardlun/archive/2009/09/08/4531576.aspx
½ñÌ죬ÖÕÓÚ°ÑoracleÖеÄÊý¾Ý¿âµ¼Èëµ½sql serverÖÐÁË£¬·½·¨ÈçÏ£º
Ò»¡¢ÔÚsql serverÖн¨¸öͬÃûÊý¾Ý¿â£¬ÀýÈçssdb¡£
¶þ¡¢ÓÒ¼üµã»÷ssdb,Ñ¡Ôñ“ËùÓÐÈÎÎñ”——>“µ¼ÈëÊý¾Ý”£¬¾Í»áµ¯³öÒ»¸ö“DTS ......