¹ØÓÚSQLSERVER ²éѯµÄÎÊÌâ
´ó¼ÒºÃ ×î½üÓöµ½µãÂé·³ Çë´ó¼Ò°ïæ ÈçÏ £º
ÎÒÔÚÒ»¸öѧÉúµÄÊý¾Ý¿â STU ÖвéѯSTUDENTS ±íÖÐ Ïà¹ØµÄÊý¾Ý
CREATE TABLE STUDENTS
(
ID INT IDENTITY(1,1) PRIMARY KEY ,
[NAME] VARCHAR(20) NOT NULL,
[CLASS] VARCHAR(10) NOT NULL,
SEX INT NOT NULL, -- 0»ò1
)
±ÈÈç ¸ù¾Ý °à¼¶ ÐÔ±ð ²éѯÐÕÃû
SELECT NAME from STUDENTS WHERE SEX=1 AND CLASS ='01°à'
²éѯ³ö 3000 ÌõÊý¾Ý
·ÖÁ½´ÎÌáÈ¡
ÎÒµÚÒ»´ÎÐèÒª 2000 Ìõ TOP 2000
µÚ¶þ´Î ÎÒÐèҪʣÏ嵀 1000 È»ºó TOP 1000 ....NOT IN... TOP 2000
ÎÒÒÔΪÕâÑù¿ÉÒÔ´ïµ½ÎÒÏ£ÍûµÄ½á¹û µ«ÊÇ
Á½´Î²é³öµÄÊý¾ÝÓкܶàÖظ´µÄ
»òÐíÓÐ ÅóÓÑ»á˵ Ä㱿°¡ Ôõô²»¼Ó ORDER BY ID
ÎÒÒ²ÖªµÀ µ«ÊÇ ORDER BY ºó ËٶȻáÏ൱µÄÂý
ËùÒÔÔÚÕâÀï ÇóÖúÀ² ÏÈлл´ó¼ÒÀ²
¿´¿´¼Ó¸öË÷Òý¿ÉÒÔ½â¾ö²»¡£
ûÓÐÅÅÐòÁÐtop»áËæ»ú·µ»ØµÄ¡£
ËٶȲ»»áÏ൱µÄÂý Ö»ÓÐ3000Êý¾Ý
order by ÊDZØÐëµÄ£¬¿ÉÒÔ¿¼ÂÇÔÚidÉϽ¨Ë÷Òý
¿ÉÒÔ¿¼ÂǼӸö¾Û¼¯Ë÷Òý....
SQL code:
SELECT TOP 1000 NAME from (SELECT DISTINCT TOP 2000 NAME from TB)AS T
¼¯ºÏÔËËã·ûEXCEPT¡£ ´Ó×ó²éѯÖзµ»ØÓÒ²éѯûÓÐÕÒµ½µÄËùÓзÇÖظ´Öµ¡£
Ïà¹ØÎÊ´ð£º
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class QueryTest&n ......
Ҫת³ÉÒ»ÑùµÄЧ¹û£¬ÓÃpowerdesignerÔõôת£¿ÄÜתÂð£¿
create table publishers (
publisherID int identity,
publisherName varchar (30) NOT NULL,
constraint pk_publishers primary key (publisherID)
)& ......
ÓÃNetBeans×Ô¶¯´´½¨ÁËÒ»¸öÊý¾Ý¿âÓ¦ÓóÌÐò£¨Ò»¸ö×ÀÃæÓ¦ÓóÌÐò£©£¬ÊµÏÖ»ù±¾µÄ¶Ô±íµÄÌí¼Ó¡¢É¾³ý¡¢Ð޸ġ¢Ë¢Ð£¬ÀïÃæÉú³ÉÁËÈý¸öÎļþ£¬Ò»¸öÊÇGUIÏÔʾ£¬Ò»¸öÊÇÈë¿ÚÎļþ£¨ launch(CarsApp3App.class, args)£©»¹ÓÐÒ»¸öÎļþ£¬Î ......
ÒÔÏ´úÂëÊÇÌí¼ÓÊý¾Ý°´Å¥µÄ´úÂ룬Ïë°Ñtestid£¬ºÍtestnameÁ½¸ötxt´«µÝµ½Êý¾Ý¿âÖÐ
Êý¾Ý¿âÁ¬½Ó¿Ï¶¨Ã»ÎÊÌâ
¾ÍÊǺìÉ«²¿·ÖÀϱ¨´í
²»ÖªµÀΪʲô-£¬-
Çë¸÷λ¸ßÈË°ïæ¿´¿´£¡
лл£¡
Java code:
private void new ......
¸÷λ´óÏÀÇë°ï°ï棬ÎÒµÄÊý¾Ý¿âÁ¬½Ó³ÌÐò³öÎÊÌâÁË£¬ÒÔÇ°Ò²¾³£ÓûáÓõ½Ëü£¬µ«ÊÇÕâÒ»´Î²»ÖªµÀΪʲôһֱ¸ã²»¶¨£¬ÏÂÃæÊÇÎÒÒªÌáÎʵÄÎÊÌ⣺,°´Àí˵ÕâÖÖÎÊÌâºÜ¼òµ¥£¬Ò»°ã¾ÍÊÇÒòΪJAR °üûÓÐÒýÈëÔì³ÉµÄ£¬¿ÉÊÇÎÒµÄJAR°ü¶¼ÒýÈë ......