Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have two tables tableA tableB
in tableA i have

ID (int)
Name
active


in tableB i have (ID foriegn key)

ID (int)
Bid (int)
Addree

my question is i have to get all values from tableB
in which i have only value in hand is "active"

in tableA
active field values are 1
ID values are different say 1,2,3,4,5

in tableB
ID vales are 1,2,3,4,5
Bid values are 6,7,8,9


i have to get all values (Addree from tableB) using active
how can i pass these values to array to get the values of tableB
Posted
Comments
[no name] 14-Dec-12 0:16am    
Can you specify if there is any relation between your tables?
sreeCoderMan 14-Dec-12 0:18am    
yes you can see ID in both tables

1 solution

you can use simple SQL Join queries to retrieve the data from the database and fill your array.

select * from tableB B right join tableA A on B.Id = A.Id where A.active = 1

more example on SQL Join Queries
http://stackoverflow.com/questions/1069205/left-and-right-joining-in-a-query[^]
http://www.tizag.com/sqlTutorial/sqljoin.php[^]
 
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