我希望从我的数据库返回2值,
这是我在2个查询中所做的:
$con = mysqli_connect("127.0.0.1",$user_database,$password_database,$nama_database) or die(" User atau Password Database tidak Valid ");
$select_total_user=mysqli_fetch_array(mysqli_query($con, "SELECT count(`acct_username`) from `pvpgn_BNET`"));
$total_user=$select_total_user[0];
$select_total_clan=mysqli_fetch_array(mysqli_query($con, "SELECT count(`name`) from `pvpgn_clan`"));
$total_clan=$select_total_clan[0];
我想要返回的值是Total Users和Total Clans 在单个查询中 感谢
答案 0 :(得分:4)
在单个查询中,可以像
一样完成select
( SELECT count(`acct_username`) from `pvpgn_BNET`) as total_user,
( SELECT count(`name`) from `pvpgn_clan` ) as total_clans ;
您可以按索引名total_user
和total_clans
答案 1 :(得分:1)
select count(acct_username) AS c1, count(name) AS c2 FROM `pvpgn_BNET`, `pvpgn_clan`;