我有四个桌子。首先存储用户数据,然后我需要根据用户选择的选项将两个或三个表连接起来。第四张桌子与第一张桌子相连
table one is plus_signupComplete
table two option_one
table three option_two
table four host_editprop2018
这是我目前的陈述
mysqli_select_db($hostStu, $database_hostStu);
$mysqli_rsOption_query = "SELECT plus_signupComplete.*, option_one.*, host_editprop2018.*, plus_signupComplete.email, option_two.* FROM option_two, ((plus_signupComplete INNER JOIN option_one ON plus_signupComplete.studentID = option_one.userID OR plus_signupComplete INNER JOIN option_two ON plus_signupComplete.studentID = option_one.userID ) ) INNER JOIN host_editprop2018 ON plus_signupComplete.prop_id = host_editprop2018.prop_id";
$rsOption = mysqli_query($hostStu, $mysqli_rsOption_query) or die(mysqli_error($hostStu));
$row_rsOption = mysqli_fetch_assoc($rsOption);
$totalRows_rsOption = mysqli_num_rows($rsOption);
所以我需要plus_signupComplete.studentID = option_one.userID或option_two.userID
我试图在MySQL中重新制作语句
$colname_rsChoose = "-1";
if (isset($_SESSION['MM_Username'])) {
$colname_rsChoose = $_SESSION['MM_Username'];
}
mysql_select_db($database_hostprop, $hostprop);
$query_rsChoose = sprintf("SELECT * FROM plus_signupComplete, option_one,
option_two, host_editprop2018 WHERE plus_signupComplete.email = %s AND (plus_signupComplete.studentID = option_one.userID OR plus_signupComplete.studentID = option_two.userID) AND plus_signupComplete.prop_id = host_editprop2018.prop_id AND plus_signupComplete.year = '2018'", GetSQLValueString($colname_rsChoose, "text"));
$rsChoose = mysql_query($query_rsChoose, $hostprop) or die(mysql_error());
$row_rsChoose = mysql_fetch_assoc($rsChoose);
$totalRows_rsChoose = mysql_num_rows($rsChoose);
但这也不起作用
预先感谢