[英]Select more tables using $query = mysql_query
Can I select more tables using this? 我可以使用此表选择更多表格吗?
$table = "users";
$query = mysql_query("SELECT title, smalltitle, FROM $table ORDER BY date DESC");
while($result= mysql_fetch_array($query))
{
echo'<div id="title"> ';
echo'<p>'.$result['title'].'</p>';
echo'</div>';
echo'<div id="name"> ';
echo'<p>'.$result['name'].'</p>';
echo'</div>';
}
I want title/smalltitle from table "users" and name/text from table "gmsg" 我想要表“ users”中的标题/小标题和表“ gmsg”中的名称/文本
Use this query - 使用此查询-
"SELECT users.title, users.smalltitle, gmsg.name FROM users, gmsg $where_condition ORDER BY users.date DESC"
$where_condition
would be the condtion to match users
& gmsg
like - $where_condition
将是匹配users
和gmsg
的条件,例如-
$where_condition = "users.id = gmsg.user_id"; //Or whatever it is
$table = "users";
$table2 = "gmsg";
$query = mysql_query("SELECT a.title, a.smalltitle, b.name, b.text FROM $table a, $table2 b ORDER BY a.date DESC");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.