疑似列

MI SQL 言語は、空間クエリを提供するために、SQL 言語上に構築されている強力なクエリ言語です。他のすべての SQL ダイアレクトと同様に、MI SQL は疑似列をサポートしています。こうした疑似列を使用すると、クエリを容易に作成できます。疑似列での大文字と小文字の区別は重要ではなく、特に説明がない限り、すべての疑似列は MI SQL ステートメントのすべてのコンストラクトで使用できます。

Obj

Obj 疑似列は、データ ソースにある空間属性の名前とは無関係に、データ ソース内の空間属性を表します。この疑似列は、MI SQL ステートメントの ORDER BY、 LIMIT および OFFSET コンストラクトでは使用できません。


; select the spatial attribute from all the features in the World 
; table
SELECT Obj FROM World
		
; select the spatial attribute from all features whose area is greater 
; than 1000 miles
SELECT Obj FROM World WHERE MI_AREA(Obj, 'sq mi', 'Spherical') > 1000
	

MI_GEOMETRY

Obj 疑似列と同じです。Obj と同じ機能および制限があります。


; select the spatial attribute from all the features in the World 
; table
SELECT mi_geometry FROM World

; select the spatial attribute from all features whose area is greater 
; than 1000 miles
SELECT mi_geometry FROM World WHERE MI_AREA(mi_geometry, 'sq
      mi', 'Spherical') > 1000
	

MI_STYLE

スタイルは MI SQL での有効なデータ タイプです。MI_STYLE 疑似列は、スタイルを保持するデータ ソース内の属性を表します。スタイル属性、よって MI_STYLE 疑似列には一定の制限があります。例えば、WHERE、ORDER BY、GROUP BY、LIMIT および OFFSET 句では使用できません。MI_STYLE 疑似列の使用は、SELECT 句でのみ有効です。


; select the style attribute from all the features in the World 
; table
SELECT mi_style FROM World
	

MI_KEY

ほとんどのデータ ソースには、データ セット内の特定の行を一意に識別するプライマリ キーの概念があります。MI SQL は、プライマリ キーを定義する属性の使用か、MI_KEY 疑似列の使用によって、プライマリ キーをサポートします。プライマリ キー疑似列は、プライマリ キーの定義に使用される属性の数とは無関係な属性です。データ ソース内の複数の属性で構成されるプライマリ キーの場合、プライマリ キーの値はプライマリ キーの各値で構成される文字列になります。この文字列の形式は、次に来る値の長さを表す数値、コロン、その値の文字列表現という並びを、必要な変数の数だけつなげたものになります。


; select the primary key from all features in the World table
SELECT MI_KEY from World

; select the POP_1990 attribute from the feature whose primary key
; equals 1
SELECT POP_1990 from World WHERE MI_KEY=1

; select the POP_1990 attribute from all the features in the World 
; table and sort the results by primary key
SELECT POP_1990 from World ORDER BY MI_KEY

; select the POP_1990 attribute from all the features in the World
; table and GROUP BY the primary key
SELECT POP_1990 from World GROUP BY MI_KEY

; select the POP_1990 attribute from the World table features with the 
; specified list of primary keys
SELECT POP_1990 from World WHERE MI_KEY in (1, 3, 4, 5, 76)

; select the POP_1990 attribute from the World table whose first primary key attribute equals 5 and second primary key equals “Hello”
SELECT POP_1990 from World WHERE MI_KEY='1:5:2:Hello'

	

Mapinfo_ID

MapInfo_ID は MI SQL クエリで使用できます。TAB データ プロバイダは、MapInfo_ID をテーブルのプライマリ キーとして公開します。DescribeTableRequest はメタデータ内の情報を返します。


<ns4:KeyDefinition keyType="Implicit">
<ns4:AttributeRef>MapInfo_ID</ns4:AttributeRef>
</ns4:KeyDefinition>


;select state from States where MapInfo_ID=2
SELECT state FROM States WHERE MapInfo_ID='2'