2014-11-03 57 views
0

我在下面使用它来将地图标记添加到Google地图。我有一个表列FIELD_NAME。有几个地点都与同一个FIELD_NAME绑定。例如,可能有5个FIELD_NAME Woods条目,每个条目都有自己的纬度/长度值。我试图弄清楚如何查询表来提供FIELD_NAME,但我只希望它显示每个名称中的一个,而不是每次使用它。获得名称后,我将使用它显示所选FIELD_NAME的所有纬度长点。你如何做到这一点,并没有任何人有任何链接到这种类型的查询教程?在Android中显示同名项目SQLite

@Override 
public void onLoadFinished(Loader<Cursor> arg0, 
    Cursor arg1) { 
int locationCount = 0; 
double lat=0; 
double lng=0; 


// Number of locations available in the SQLite database table 
locationCount = arg1.getCount(); 

// Move the current record pointer to the first row of the table 
arg1.moveToFirst(); 

for(int i=0;i<locationCount;i++){ 

    // Get the latitude 


    name = arg1.getString(arg1.getColumnIndex(LocationsDB.FIELD_NAME)); 

    lacomments = arg1.getString(arg1.getColumnIndex(LocationsDB.FIELD_COMMENTS)); 

    lat = arg1.getDouble(arg1.getColumnIndex(LocationsDB.FIELD_LAT)); 

    // Get the longitude 
    lng = arg1.getDouble(arg1.getColumnIndex(LocationsDB.FIELD_LNG)); 






    // Creating an instance of LatLng to plot the location in Google Maps 
    locationEngine = new LatLng(lat, lng); 


    MarkerOptions markerOptions = new MarkerOptions();     

     markerOptions.position(locationEngine); 

     // Adding marker on the Google Map 
     getMap().addMarker(markerOptions); 




    arg1.moveToNext(); 


} 

}如果要填充不同FIELD_NAME在一些微调,然后在它的选择显示所有的位置,更好地与2个查询做

绑定结果微调

+0

您是否试图在SQL查询中的[WHERE](http://www.techonthenet.com/sql/where.php)子句上进行搜索?它会直接返回你想要的行。 – calimbak 2014-11-03 01:45:57

回答

1

的 “选择从表名不同FIELD_NAME”

,然后一旦用户提供他的选择,可使用下面的查询

SELECT * FROM表名其中field_name =“whatever_user_selected”

注:表名 - 替换为您表的名称

让我知道,如果没有供用户选择用户界面和你想为一个特定的随机 项字段