我當前的腳本從數據庫中提取一個值,分解位置並將其輸入到Google的地理編碼API中。有沒有辦法查詢我的數據庫,以便空白值被跳過?
但是,一些組織(爲此我拉的位置)是空白的。例如,我將有
Org#1 Alabama
Org#2 Kentucky
Org#3
Org#4 California
我知道我可以使用if/else語句來過濾掉空項,但我想知道是否有辦法從我的數據庫查詢做到這一點,這樣額外的腳本時間不浪費只是篩選出空的條目。
我當前的查詢是這樣的:
$sql = "SELECT Name As org FROM Orgs WHERE Org=".$Org; // get organization that matches org ID
$org = sql_return_one_number($db_connection, $sql); // magic
$orgrep = str_replace(" ", "+", $org); //remove all spaces and add a + sign for google API purposes
$latlong = file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address=$orgrep&sensor=false&key=KEY"); // pass info to google
$output=json_decode($latlong); //store it
$status=$output->status;
是否所有的結果都來自分貝與 '組織#_'? –
是的,組織編號或組織編號是我們所有組織的數字標識符。 Org ID與計數器和組織的最大組合一起使用,以便當腳本到達組織的最後組織時,該腳本將在組織#1處重新開始。 – lbaile200
你不能只是和你的SQL的「和Org <>」'「嗎? – durbnpoisn