Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C C# ASP HTML ASP:NET
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 13-Dec-12 18:58pm
Comments
sreeCoderMan at 14-Dec-12 0:18am
   
yes you can see ID in both tables

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  

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

  Print Answers RSS
0 Maciej Los 580
1 OriginalGriff 420
2 Sascha Lefévre 289
3 CHill60 225
4 Abhinav S 220
0 Sergey Alexandrovich Kryukov 9,773
1 OriginalGriff 9,290
2 Peter Leow 5,137
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,036


Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100