如何将多个值从数据库传递到数组? [英] How to pass multiple values from database to an array?
问题描述
我有两张桌子桌子一张桌子
in tableA我有
ID(int)
名称
活跃
in tableB我有(ID foriegn key)
ID(int)
买入(int)
Addree
my问题是我必须得到来自tableB的所有值
其中我只有手中的值是活跃的
in tableA
有效字段值为1
ID值不同说1,2,3,4,5
in tableB
ID值是1,2,3,4,5
买入价为6,7,8,9
>
i必须得到所有值(来自tableB的Addree)使用active
如何将这些值传递给数组以获取tableB
您可以使用简单的SQL Join查询从数据库中检索数据并填充数组。
select *来自tableB B右边的joi n表A.A在B.Id = A.Id其中A.active = 1
关于SQL Join查询的更多示例
http://stackoverflow.com/questions/1069205/left-and-right-joining-in -a-query [ ^ ]
http://www.tizag.com/sqlTutorial/ sqljoin.php [ ^ ]
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
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[^]
这篇关于如何将多个值从数据库传递到数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!