不同表的数据,我有两个不同的表,Country_m和State_m合并两个由SQL
的State
表有字段,如StateId, Name, CountryId, etc
,并且Country
表有一个像CountryId, Name, Currency, etc
的Fileds。
我想获得一个状态表的数据网格,它应该打印状态名称和相应的国家名称...如何执行此查询?
不同表的数据,我有两个不同的表,Country_m和State_m合并两个由SQL
的State
表有字段,如StateId, Name, CountryId, etc
,并且Country
表有一个像CountryId, Name, Currency, etc
的Fileds。
我想获得一个状态表的数据网格,它应该打印状态名称和相应的国家名称...如何执行此查询?
select t1.Name state_name, t2.Name Country_name from State_m t1,Country_m t2 where t1.CountryId=t2.CountryId;
使用thsi
试试这个
select s.name as STATENAME,c.name AS COUNTRYNAME from state s
inner join country c
on s.countryid=c.countryid
thnx ...它的工作以及:) – Azzy
这是一个加入。这可能是一个好主意,先了解他们:
这是最简单的... thnx :) – Azzy