找出所有首都和其國家名字,而首都要有國家名字中出現。
select capital,name from world
where name in (capital) 我寫的 正確答案應該是下面
capital name
Andorra la Vella Andorra
Djibouti Djibouti
Guatemala City Guatemala
Kuwait City Kuwait
Luxembourg Luxembourg
Mexico City Mexico
Monaco-Ville Monaco
Panama City Panama
San Marino San Marino
Singapore Singapore
12 个解决方案
#1
[请贴出表结构、测试数据的脚本……,
select capital,name from world where charindex(name,capital )>0
, capital name
Kabul Afghanistan
Tirana Albania
Algiers Algeria
Andorra la Vella Andorra
Luanda Angola
St. John's Antigua and Barbuda
Buenos Aires Argentina
Yerevan Armenia
Canberra Australia
Vienna Austria
Baku Azerbaijan
Nassau Bahamas
Manama Bahrain
Dhaka Bangladesh
Bridgetown Barbados
Minsk Belarus
City of Brussels Belgium
Belmopan Belize
Porto-Novo Benin
Thimphu Bhutan
Sucre Bolivia
Sarajevo Bosnia and Herzegovina
Gaborone Botswana
Brasília Brazil
Bandar Seri Begawan Brunei
Sofia Bulgaria
Ouagadougou Burkina Faso
Bujumbura Burundi
Phnom Penh Cambodia
Yaoundé Cameroon
Ottowa Canada
Praia Cape Verde
Bangui Central African Republic
N'Djamena Chad
Santiago Chile
Beijing China
Bogotá Colombia
Moroni Comoros
Kinshasa Congo, Democratic Republic of
Brazzaville Congo, Republic of
San José Costa Rica
Yamoussoukro Côte d'Ivoire
Zagreb Croatia
Havana Cuba
Nicosia Cyprus
Prague Czech Republic
Copenhagen Denmark
Djibouti Djibouti
Roseau Dominica
Santo Domingo Dominican Republic
原表就是這樣的 ,
你這個試了不行 ,
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
怎么会不行呢,你的是不是sql server啊,
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
怎么会不行呢,你的是不是sql server啊
我這個是在綫試題 ,
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
Error:
execute command denied to user 'scott'@'localhost' for routine 'gisq.charindex' 這就是結果 我是複製你的答案
行不行不是你說了算 是數據說了算 我是不懂 你不原意答就不答 牛轟轟的不耐煩沒必要吧 ,
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
Error:
execute command denied to user 'scott'@'localhost' for routine 'gisq.charindex' 這就是結果 我是複製你的答案
行不行不是你說了算 是數據說了算 我是不懂 你不原意答就不答 牛轟轟的不耐煩沒必要吧
這裡面人素質真差 真是醉了。。。
别说没用的 呵呵 , 应该是 mysql ,
应该是 mysql
my什么都不管了,恼火啊,
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
select capital,name from world where charindex(name,capital )>0
, capital name
Kabul Afghanistan
Tirana Albania
Algiers Algeria
Andorra la Vella Andorra
Luanda Angola
St. John's Antigua and Barbuda
Buenos Aires Argentina
Yerevan Armenia
Canberra Australia
Vienna Austria
Baku Azerbaijan
Nassau Bahamas
Manama Bahrain
Dhaka Bangladesh
Bridgetown Barbados
Minsk Belarus
City of Brussels Belgium
Belmopan Belize
Porto-Novo Benin
Thimphu Bhutan
Sucre Bolivia
Sarajevo Bosnia and Herzegovina
Gaborone Botswana
Brasília Brazil
Bandar Seri Begawan Brunei
Sofia Bulgaria
Ouagadougou Burkina Faso
Bujumbura Burundi
Phnom Penh Cambodia
Yaoundé Cameroon
Ottowa Canada
Praia Cape Verde
Bangui Central African Republic
N'Djamena Chad
Santiago Chile
Beijing China
Bogotá Colombia
Moroni Comoros
Kinshasa Congo, Democratic Republic of
Brazzaville Congo, Republic of
San José Costa Rica
Yamoussoukro Côte d'Ivoire
Zagreb Croatia
Havana Cuba
Nicosia Cyprus
Prague Czech Republic
Copenhagen Denmark
Djibouti Djibouti
Roseau Dominica
Santo Domingo Dominican Republic
原表就是這樣的 ,
select capital,name from world where charindex(name,capital )>0
你這個試了不行 ,
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
怎么会不行呢,你的是不是sql server啊,
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
怎么会不行呢,你的是不是sql server啊
我這個是在綫試題 ,
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
Error:
execute command denied to user 'scott'@'localhost' for routine 'gisq.charindex' 這就是結果 我是複製你的答案
行不行不是你說了算 是數據說了算 我是不懂 你不原意答就不答 牛轟轟的不耐煩沒必要吧 ,
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0
Error:
execute command denied to user 'scott'@'localhost' for routine 'gisq.charindex' 這就是結果 我是複製你的答案
行不行不是你說了算 是數據說了算 我是不懂 你不原意答就不答 牛轟轟的不耐煩沒必要吧
這裡面人素質真差 真是醉了。。。
别说没用的 呵呵 , 应该是 mysql ,
应该是 mysql
my什么都不管了,恼火啊,
select capital,name from world where charindex(name,capital )>0
你這個試了不行
--> --> 听雨停了-->生成测试数据
if not object_id(N'Tempdb..#tab') is null drop table #tab Go Create table #tab([capital] nvarchar(27),[name] nvarchar(31)) Insert #tab select N'Kabul',N'Afghanistan' union all select N'Tirana',N'Albania' union all select N'Algiers',N'Algeria' UNION ALL SELECT 'Kuwait City','Kuwait' UNION ALL SELECT 'Djibouti','Djibouti' Go Select * from #tab WHERE charindex(name,capital )>0