问题描述
有两个表
1.注册
ID主键自动递增
经销商名称,
手机,
Dob等.
2.产品
用户ID主键自动递增,
过帐类型(有出售和出租两种选择)
id外键
地址,
城市
价格,位置
和RadioButtonList
,其中包含两个项目1:卖出2:出租
我希望如果选择了卖出,然后从第一个表中检索经销商名称和移动电话,并从第二个表中检索地址,城市,价格和地区,并通过选择的单选按钮满足条件.
请帮帮我吗?
There are two table
1.registration
Id primary key auto increment
dealer name,
mobile,
dob etc.
2.product
userid primary key auto increment,
Posting type(which have two option sell and rent)
id foreign key
address,
city
price,locality
and a RadioButtonList
with two items 1:Sell 2:Rent
I want that if sell is selected then retrieve dealer name and mobile from first table and address, city, price and locality from second table where condition is met with selected radio button.
Please help me?
推荐答案
SELECT R.dealer name,R.Mobile,P.address,P.city,price,P.locality FROM registration R INNER JOIN Product P ON R.Id=P.Id
如果您想从两个表中获取数据,则需要加入
请参考以下链接
http://www.w3schools.com/sql/sql_join_inner.asp [ ^ ]
http://msdn.microsoft.com/en-us/library/ms191517%28v = SQL.90%29.aspx [ ^ ]
If u want to get data from two tables you need join
Refer following links
http://www.w3schools.com/sql/sql_join_inner.asp[^]
http://msdn.microsoft.com/en-us/library/ms191517%28v=SQL.90%29.aspx[^]
这篇关于如何一次获取两个表数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!