Professional Documents
Culture Documents
2
1 SQL .............................................................................................................................................................2
2 ..................................................................................................................................................2
3 ..............................................................................................................................................................................3
4 SQL .....................................................................................................................................................4
SQL EXPRESSION..........................................................................................6
1
1.1
.........................................................................................................................................................6
1.1.1 (Extract)................................................................................................................................................................6
1.1.2 (Conversion).......................................................................................................................................................6
1.1.3 ...............................................................................................................................................................................7
1.2
.........................................................................................................................................................7
1.2.1 ...............................................................................................................................................................................7
1.2.2 ...............................................................................................................................................................................8
1.3
.........................................................................................................................................................8
2.1
-..................................................................................................................................10
2.2
-..........................................................................................................11
2.3
"and" "or".............................................................................................................................................11
2.4
2.5
SQL ..............................................................................................................................................12
2.6
Null................................................................................................................................................................12
2.7
2.8
sql ................................................................................................................................................14
ADO CONNECTION.......................................................................................................................................21
SQL (UPDATE)...............................................................................................................................22
................................................................................................................................23
(lucy11149@163.com)
(tj051181@gmail.com)
ESRI
--- ArcMap SQL
SQL(Structured Query Language)
SQL SQL
ArcMap SQL
SQL
SQL SQL
SQL 4
1 (DDL)CREATEDROPALTER
2 (DML)INSERTUPDATEDELETE
3 (DQL)SELECT
4 (DCL)GRANTREVOKECOMMITROLLBACK
ArcMap 23 select
1 SQL
select * from table1 where
insert into table1(field1,field2) values(value1,value2)
delete from table1 where
update table1 set field1=value1 where
select * from table1 where field1 like %value1% ---like !
select * from table1 order by field1,field2 [desc]
select count as totalcount from table1
select sum(field1) as sumvalue from table1
select avg(field1) as avgvalue from table1
select max(field1) as maxvalue from table1
select min(field1) as minvalue from table1
2
1UNION
UNION TABLE1 TABLE2
ALL UNION UNION ALL
TABLE1 TABLE2
(lucy11149@163.com)
(tj051181@gmail.com)
2EXCEPT
EXCEPT TABLE1 TABLE2
ALL EXCEPT (EXCEPT ALL)
3 INTERSECT
INTERSECT TABLE1 TABLE2
ALL INTERSECT (INTERSECT ALL)
3
1. INNER JOIN 2. LEFT JOIN
ID
NAME
ID
CLASS
IBM
C1
SONY
C3
BMW
C4
ID
NAME
CLASS
IBM
C1
BMW
C3
ID
2 LEFT JOIN : SELECT * FROM
ID
NAME
CLASS
IBM
C1
SONY
null
BMW
C3
A(left ) B
3
RIGHT JOIN :
SELECT * FROM
RIGHT()
ID
NAME
CLASS
IBM
C1
BMW
C3
null
C4
B(right ) A
SELECT * FROM
ID
NAME
CLASS
IBM
C1
(lucy11149@163.com)
(tj051181@gmail.com)
SONY
null
BMW
C3
null
C4
4 SQL
mysql access
1(,a b) (Access )
select * into b from a where 1<>1
select top 0 * into b from a
2(,a b) (Access )
insert into b(a, b, c) select d,e,f from b;
3() (Access )
insert into b(a, b, c) select d,e,f from b in where
insert into b(a, b, c) select d,e,f from [].b where
..from b in "&Server.MapPath(".")&"\data.mdb" &" where..
4( 1a 2b)
select a,b,c from a where a IN (select d from b ) : select a,b,c from a where a IN (1,2,3)
5
select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table
where table.title=a.title) b
6( 1a 2b)
select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c
7( 1a )
select * from (Select a,b,c FROM a) T where t.a > 1;
8between ,between ,not between
select * from table1 where time between time1 and time2
select a,b,c, from table1 where a not between 1 and 2
9in
select * from table1 where a [not] in ( 1, 2, 4, 6)
10
delete from table1 where not exists ( select * from table2 where table1.field1=table2.field1 )
11
select * from a left inner join b on a.a=b.b right inner join c on a.a=c.c inner join d on a.a=d.d
where .....
12
select * from where datediff(minute,f ,getdate())>5
13 SQL
select top 10 b.* from (select top 20 , from order by desc) a,
(lucy11149@163.com)
(tj051181@gmail.com)
b where b. = a. order by a.
14 10
select top 10 * form table1 where
15 b a (
,,,.)
select a,b,c from tablename ta where a=(select max(a) from tablename tb where tb.b=ta.b)
16 TableA TableB TableC
(select a from tableA ) except (select a from tableB) except (select a from tableC)
17 10
select top 10 * from tablename order by rnd(id )
18
select rnd( id )
19
Delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)
20
select name from sysobjects where type=U
21
select name from syscolumns where id=object_id(TableName)
22 typevenderpcs type case
select case
select type,sum(case vender when A then pcs else 0 end),sum(case vender when C
then pcs else 0 end),sum(case vender when B then pcs else 0 end) FROM tablename group by
type
type
vender
pcs
23 10 15
select top 5 * from (select top 15 * from table order by id asc) table_ order by id desc
ArcMap
ArcMap SQL
(lucy11149@163.com)
(tj051181@gmail.com)
SQL Expression
SQLArcMapSQL ExpressionESRI
SQL Reference
1 SQL ExpressionArcMap
SQL Expression
1.1
1.1.1 (Extract)
Query Builder
Select
Analysis\Extract
Table Select
Analysis\Extract
Extract by Attributes
Spatial\Analyst
Conversion\To Geodatabase
Table To Table
Conversion\To Geodatabase
CADLinestoPolygonFeatures
CAD
1.1.2 (Conversion)
1.1.3
Select By Attribut
Tools
Field Calculator
set Null
Spatial Analyst\Conditional
1.2
1.2.1
Layer Properties\ Definition Query Distributed Geodatabase
Query Definition Query Get Cout
(lucy11149@163.com)
(tj051181@gmail.com)
1.2.2
Layer Properties\ Labels \ classes labels SQL Expression
Lable
http://bbs.esrichina-bj.cn/esri/viewthread.php?tid=55808
1.3
1.3.1 Layer
ArcGIS
layer 2
Tools\Select by Attribute
(lucy11149@163.com)
(tj051181@gmail.com)
1.3.2 ModelBuilder
SQL Expression CAD polyline annotation
CAD Lines to Polygon Features (Samples) 1.1.2
SQL Expression Create Variable
1.3.3 (LinearReferencing)
Diligentpig ArcGIS /
http://bbs.esrichina-bj.cn/esri/viewthread.php?tid=56638
(lucy11149@163.com)
(tj051181@gmail.com)
2 SQLExpression
SQL WHERE
.1
2.1 -
1 dltb dlbm 011
[DLBM] =011
(lucy11149@163.com)
(tj051181@gmail.com)
10
2.2 -
(1) dltb dlbm 01
Left(TRIM([dlbm]),2)=01
(2) dlmc
[dlmc] like **
Personal Geodatabase
shapefile
Function
Examples
Function
Examples
mod
[] mod 2 = 0
mod
mod("",2)=0
left
left([],2)="Ts"
substr
substr("",1,2)=Ts
mid
mid([],2,2)="so"
substr
substr("",2,2)=so
2 2
len
len([])= 4
char_length
char_length( "" ) = 4
instr
instr([],"o")=2
position
position(o in "") = 2
a A
[]="tsonghua"
lcase
lcase([])="tsonghua"
ucase
#wildcard#
#[]#
ucase([
])="TSONGHUA"
[] > 2 ; [] = "2"
[] like "2*" or []
like "?2"
[BIRTH] = #06-13-2001
19:30:00#
pGDB lower()
lower
lower("")=tsonghua
pGDB Lcase()
upper
#wildcard#
date
upper("
")=TSONGHUA
"" > 2 : "" = 2
"" like 2% or ""
like _2
VS. % & _
pGDB #fGDB
19:30:00
date
PGDB shp
http://bbs.esrichina-bj.cn/esri/viewthread.php?tid=60118
11
[dlbm]= 011 or [dlbm]= 012 or [dlbm]= 013
in
[dlbm] in (011, 012,013)
in not in
2.5 SQL
1 10
[OBJECTID]
2 OBJECTID 11 15
[OBJECTID]
in
(select top 5 OBJECTID from (select top 15 * from dltb order by OBJECTID asc) b
http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=55857
sql
http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=53458
http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=54652
2.6 Null
<Null> "Null" ""0 Null
Null Null [] is Null [] = Null
(lucy11149@163.com)
(tj051181@gmail.com)
12
? _
* %
(0 - 9)
[]
[!]
([ ])
ANSI ANSI Microsoft Windows 8
256 0 255ASCII ANSI ANSI Microsoft
Windows 8 256 0 255
ASCII
ANSI ([ )
(?) (#) (*) ( ])
(-)
[A-Z] A Z
[a-zA-Z0-9]
1. (!)
2. (-)
ANSI
3.A-Z 0-100[A-Z] [Z-A]
4. [ ]
("
")
(" ") ("")
(lucy11149@163.com)
(tj051181@gmail.com)
13
True
False
a*a
aaaBaaBBBa
aBC
*ab*
abcAABBXab
aZbbac
a[*]a
a*a
aaa
ab*
abcdefgabc
cabaab
a?a
aaaa3aaBa
aBBBa
a#a
a0aa1aa2a
aaaa10a
[a-z]
fpj
2&
[!a-z]
9&%
ba
[!0-9]
Aa&~
019
a[!b-m]#
An9az0a99
abcaj0
P A F
Like P[A-F]###
2.8 sql
[OBJECTID]
(lucy11149@163.com)
(tj051181@gmail.com)
14
Field CalculatorSQL
ArcGIS
Field CalculatorSql
Field Calculator Flag
Model Builder
Make Feature Layer SQL Expression Calculate Field
(lucy11149@163.com)
(tj051181@gmail.com)
15
16
Dim scommand
i = 0 0
Set pMxDoc = ThisDocument
Set pdl2 = pMxDoc.FocusMap.Layer(i)
Set pDSName = pdl2.DataSourceName
Dim pWorkspaceFactory As IWorkspaceFactory
Dim pWorkspace As IWorkspace
Set pWorkspaceFactory = New AccessWorkspaceFactory
Set pWorkspace = pWorkspaceFactory.OpenFromFile(pDSName.WorkspaceName.PathName, 0)
-------------------------------------------------------
pWorkspace.ExecuteSQL scommand
flag = 1
end if
Field Calculator
SQL SQL
2 - dlbm1 dlmc1
scommand
(lucy11149@163.com)
(tj051181@gmail.com)
17
ArcGIS Desktop
http://bbs.esrichina-bj.cn/ESRI/thread-67896-1-3.html
SQL
(lucy11149@163.com)
(tj051181@gmail.com)
18
19
dltb.OBJECTID_1=b.fid_dltb set
dltb.xzdwmj=b.mj"
pWorkspace.ExecuteSQL scommand
scommand = "DROP TABLE temp_luys"
pWorkspace.ExecuteSQL scommand
flag = 1
end if
Workspace
sql Sql
(lucy11149@163.com)
(tj051181@gmail.com)
20
VBEADOSQL
personal Geodatabase
MS Access personal Geodatabase Microsoft ActiveX Data
Objects 2.x SQL
ADO Connection
21
Public Rs As ADODB.RecordSet
Public strSql As String
Public strMDBpath As String
' --------------------------------------------------------------------------'* : Cn
'* : mdbpath
'*
String
: Tsonghua
'* : 2010-06-26
' ---------------------------------------------------------------------------
SQL (update)
String
'*
String
SQL
sql
'*
: Tsonghua
'* : 2010-06-26
' ---------------------------------------------------------------------------
22
Cn.Close
End Sub
sql
'*
String
String
SQL
: Tsonghua
'* : 2010-06-26
' ---------------------------------------------------------------------------
(lucy11149@163.com)
(tj051181@gmail.com)
23
@Shanghai
6/26/2010 6:08:01 PM
(lucy11149@163.com)
(tj051181@gmail.com)
24