免費論壇 繁體 | 簡體
Sclub交友聊天~加入聊天室當版主
分享
Board logo

標題: city-2 [打印本頁]

作者: Smallcat    時間: 2019-12-11 21:58     標題: city-2

  1. drop database if exists CITYDATABASE;
  2. create database CITYDATABASE;
  3. use CITYDATABASE;
  4. drop table if exists CITYTABLE;
  5. create table CITYTABLE(ID numeric,COUNTRY varchar(50),CITY varchar(60),LAT numeric(11,8),LON numeric(11,8));
  6. load data infile 'C:/test/city.csv' into table CITYTABLE fields terminated by ',' enclosed by '"' lines terminated by '\n' ignore 1 rows;
  7. SET SQL_SAFE_UPDATES=0;

  8. select ID,COUNTRY,CITY,round(LAT,1),round(LON,1) from CITYTABLE order by CITY,ID asc;
  9. select ID,COUNTRY,CITY,round(LAT,1),round(LON,1)
  10. from (select ID,COUNTRY,CITY,round(LAT,1),round(LON,1)FROM CITYTABLE group by round(LON,1),round(LAT,1))
  11. order by CITY,ID asc;

  12. select ID,COUNTRY,CITY,round(LAT,1),round(LON,1)
  13. FROM CITYTABLE group by round(LON,1),round(LAT,1)
  14. order by CITY,ID asc;

  15. select distinct CITY from CITYTABLE;
複製代碼

作者: Smallcat    時間: 2019-12-25 17:57

  1. drop database if exists CITYDATABASE;
  2. create database CITYDATABASE;
  3. use CITYDATABASE;
  4. drop table if exists CITYTABLE;
  5. create table CITYTABLE(ID numeric,COUNTRY varchar(50),CITY varchar(60),LAT numeric(11,8),LON numeric(11,8));
  6. load data infile 'C:/test/city.csv' into table CITYTABLE
  7. fields terminated by ',' enclosed by '"' lines terminated by '\n' ignore 1 rows;
  8. SET SQL_SAFE_UPDATES=0;

  9. select LAT,LON from (select ID,COUNTRY,CITY,round(LAT,3) AS LAT,round(LON,3) AS LON FROM CITYTABLE group by round(LON,3),round(LAT,3)) as t1 order by CITY desc,ID limit 3,3;

  10. select round(LAT,3) AS LAT,round(LON,3) AS LON
  11. FROM CITYTABLE group by round(LON,3),round(LAT,3);

  12. select round(LAT,3) AS LAT,round(LON,3) AS LON
  13. FROM CITYTABLE group by round(LON,3),round(LAT,3) limit 5,15;
複製代碼





歡迎光臨 小貓貓大聯盟!幻與想的境界\(0w0)/ (http://smallcat.utmall.com/) Powered by Discuz! 7.2