WHERE 子句中的多个查询
Multiple queries in WHERE clause
遇到这个问题..我的 sql 查询在 PHP myAdmin 中有效,但在页面上无效..
url:
http://www.copleycaravanservices.co.uk/Caravans.php?room_id=1&foreign_id=1
还有另一个查询适用于 url
的 room_id 部分
无效的代码:
<?php
require_once('db_config.php');
mysql_select_db($dbname, $db);
$sql1 = "SELECT * FROM `SS_hotel_booking_multi_lang`
WHERE `foreign_id` = " . $_GET['foreign_id'] . "
AND `locale` = '1'
AND `field` = 'description'
AND `source` = 'data'";
$result1 = mysql_query($sql1, $db) or die(mysql_error());
$CaravanDesc = mysql_fetch_assoc($result1);
?>
数据库:(希望这能正确显示!)
id foreign_id model locale field content source
7365 1 pjRoom 1 name Promenade 654 data
7366 1 pjRoom 1 description This caravan sleeps 6 data
7371 2 pjRoom 1 name Butlins Sandhills 14 data
7372 2 pjRoom 1 description 4 Day Passes included data
我认为应该像这样尝试删除列名的引号
<?php
require_once('db_config.php');
mysql_select_db($dbname, $db);
$sql1 = "SELECT * FROM `SS_hotel_booking_multi_lang`
WHERE foreign_id = " . $_GET['foreign_id'] . "
AND locale = '1'
AND field = 'description'
AND source = 'data'";
$result1 = mysql_query($sql1, $db) or die(mysql_error());
$CaravanDesc = mysql_fetch_assoc($result1);
?>
遇到这个问题..我的 sql 查询在 PHP myAdmin 中有效,但在页面上无效..
url: http://www.copleycaravanservices.co.uk/Caravans.php?room_id=1&foreign_id=1 还有另一个查询适用于 url
的 room_id 部分无效的代码:
<?php
require_once('db_config.php');
mysql_select_db($dbname, $db);
$sql1 = "SELECT * FROM `SS_hotel_booking_multi_lang`
WHERE `foreign_id` = " . $_GET['foreign_id'] . "
AND `locale` = '1'
AND `field` = 'description'
AND `source` = 'data'";
$result1 = mysql_query($sql1, $db) or die(mysql_error());
$CaravanDesc = mysql_fetch_assoc($result1);
?>
数据库:(希望这能正确显示!)
id foreign_id model locale field content source
7365 1 pjRoom 1 name Promenade 654 data
7366 1 pjRoom 1 description This caravan sleeps 6 data
7371 2 pjRoom 1 name Butlins Sandhills 14 data
7372 2 pjRoom 1 description 4 Day Passes included data
我认为应该像这样尝试删除列名的引号
<?php
require_once('db_config.php');
mysql_select_db($dbname, $db);
$sql1 = "SELECT * FROM `SS_hotel_booking_multi_lang`
WHERE foreign_id = " . $_GET['foreign_id'] . "
AND locale = '1'
AND field = 'description'
AND source = 'data'";
$result1 = mysql_query($sql1, $db) or die(mysql_error());
$CaravanDesc = mysql_fetch_assoc($result1);
?>