使用第一个查询中的变量从第二个查询中获取结果时出错

ar7v8xwq  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(358)

然而,当我想在where条件下的第二个查询中使用它们时,我从第一个查询中正确地得到了结果,我得到了查询错误1064。如果我把它移到哪里就好了。另外,当我在第二个查询代码中尝试回显内部变量时,它将打印出来

$queryDate = "SELECT date , time from DATES where ID = $ID";
	$result = mysqli_query($connection, $queryDate);

	if ($result->num_rows > 0) {
	     while($row = $result->fetch_assoc()) {

			$date = $row['date']; 
			$time = $row['time'];

		 } 
	}

	$queryCom = "SELECT * from DATES, BOOKING where dates.time = $time and booking.IDofFullDate= $date";
	$result1 = mysqli_query($connection, $queryCom);
	if (!$result1)
				{

					die("Query Faile".  mysqli_errno($connection));   
				}

	if ($result1->num_rows >0) {
			  echo $date;
			  echo $time;
	}
ccrfmcuu

ccrfmcuu1#

在第二个查询中,请尝试以下操作:

$queryCom = "SELECT * from DATES as dates, BOOKING as booking where dates.time = $time and booking.IDofFullDate= $date";

相关问题