Click here to Skip to main content
15,909,051 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Updated 29-Sep-11 1:42am
v3

Use the Left outer join, where first table will be registration and second would be product,

problem with inner join if there is no matching record found in the second table then data will not be displayed,

read more about joins:

http://blog.sqlauthority.com/2009/04/13/sql-server-introduction-to-joins-basic-of-joins/[^]


Hope this will help:
 
Share this answer
 
You have to use innerjoins in your SQL query if you need to retrieve data from 2 tables , be sure that these two tables are connected to each other with a primary key.


You can get a brief intro about inner joins in the link below.

http://www.w3schools.com/sql/sql_join_inner.asp[^]
 
Share this answer
 
In CheckeChanged Event of radio button, Write the query like this

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



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[^]
 
Share this answer
 
v2
Please claify you are writing directly queries or using and OR mapper like Like LinQto SQl or entity framework.
 
Share this answer
 
Hi,

try this query for your requirement.

C#
string query="select R.name,R.mobile,P.address,P.city,P.price,P.locality from registration as R,product as P where P.id=R.id and P.[Posting type]='"+Radiobtn.SelectedValue+"'";



All the Best
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900