SQL:查询以识别国家/城市 [英] SQL: Query to Identify Countries/ cities

查看:471
本文介绍了SQL:查询以识别国家/城市的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好 - 我有桌子,其中一列的值如下所示。 
$


示例: 

创建表国家(CityCountry varchar(100));

插入国家



('芝加哥,IL'),
('Richmond,VA'),

('Jefferson,WI'),
('Brampton,ON'),

('Halifax,NS'),

('孟买,In'),

('伦敦,ENG');



这就是我需要输出的方式:



A栏              B栏
伊利诺伊州芝加哥            Local 

Richmond,VA        Local 

Jefferson,WI       本地 

布兰普顿,ON     外国

哈利法克斯,NS         外国人b $ b孟买,In         外国人b $ b伦敦,ENG       外国
b $ b b
除美国城市/国家外,所有其他城市/国家均应命名为外国人。如何编写SQL查询?我已经在表格中获得了超过100的价值。


Hi Guys - I have table, where one of the column has values like below. 

Example: 
create table Country (CityCountry varchar(100));
insert into Country
values
('Chicago, IL'),
('Richmond, VA'),
('Jefferson, WI'),
('Brampton, ON'),
('Halifax, NS'),
('Mumbai, In'),
('London, ENG');

This is how i need output:

Column A             Column B
Chicago, IL           Local 
Richmond, VA       Local 
Jefferson, WI        Local 
Brampton, ON      Foreign
Halifax, NS          Foreign
Mumbai, In          Foreign
London, ENG        Foreign

Except USA cities/States all other should be named as foreign. How to write a SQL query ? I have got over 100's of values in the table.

推荐答案

嗨大家好 - 我有桌子,其中一列的值如下所示。 
$


示例: 

$
A栏

芝加哥,伊利诺伊州。
里士满,弗吉尼亚州。
Jefferson,WI

Brampton,ON

Halifax,NS

孟买,在¥b $ b伦敦,ENG¥


这是我需要输出的方式:



A栏              B栏
伊利诺伊州芝加哥            Local 

Richmond,VA        Local 

Jefferson,WI       本地 

布兰普顿,ON     外国

哈利法克斯,NS         外国人b $ b孟买,In         外国人b $ b伦敦,ENG       外国
b $ b b
除美国城市/国家外,所有其他城市/国家均应命名为外国人。如何编写SQL查询?我在表中得到了超过100的价值。

Hi Guys - I have table, where one of the column has values like below. 

Example: 

Column A
Chicago, IL
Richmond, VA
Jefferson, WI
Brampton, ON
Halifax, NS
Mumbai, In
London, ENG

This is how i need output:

Column A             Column B
Chicago, IL           Local 
Richmond, VA       Local 
Jefferson, WI        Local 
Brampton, ON      Foreign
Halifax, NS          Foreign
Mumbai, In          Foreign
London, ENG        Foreign

Except USA cities/States all other should be named as foreign. How to write a SQL query ? I have got over 100's of values in the table.

美好的一天
kkran

请发布查询以创建表并插入一些示例数据,而不是有关表结构的故事。查询将比任何描述更好地为我们提供有关结构的所有信息。此外,查询将让我们在服务器中创建
表,插入样本数据,并为您提供快速解决方案: - )

Please post queries to create the table and insert some sample data, instead of stories about the table structure. The queries will give us all the information regarding the structure better then any description. Moreover, the queries will let us create the table in our server, insert the sample data, and provide you a fast solution :-)


这篇关于SQL:查询以识别国家/城市的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆