手动查询Ms sql

时间:2013-08-28 02:09:08

标签: php sql sql-server

我正在使用带有php的ms sql server我需要知道我做错了什么,因为我没有从数据库中获取任何数据。我知道我已经连接,我知道列是正确的名称以及表单名称。当我转储结果时,它会显示类型的资源(6) (mssql结果)。

这是我的询问。

$query = "SELECT *
FROM [ERCOT_Data].[dbo].[TDSP_ESIID]
WHERE ADDRESS LIKE '%$house_num%'
  AND ADDRESS LIKE '%$street%'
  AND ZIPCODE LIKE '%$zip%'
  AND CITY LIKE '%$city%'";

我也试过这个

$query = "SELECT *
FROM [ERCOT_Data].[dbo].[TDSP_ESIID]
WHERE ADDRESS LIKE '$house_num%'
  AND ADDRESS LIKE '$street%'
  AND ZIPCODE LIKE '$zip%'
  AND CITY LIKE '$city%' ";

2 个答案:

答案 0 :(得分:0)

试试这个

$query = "SELECT *
FROM [php].[dbo].[TDSP_ESIID]
WHERE ADDRESS LIKE '".$house_num%'."
AND ADDRESS LIKE '".$street%'."
AND ZIPCODE LIKE '".$zip%'."
AND CITY LIKE '$city%' ";

答案 1 :(得分:0)

试试这个!

最好将PHP变量放在字符串之外

$query = "SELECT *
FROM [ERCOT_Data].[dbo].[TDSP_ESIID]
WHERE ADDRESS LIKE '".$house_num."%'
  AND ADDRESS LIKE '".$street."%'
  AND ZIPCODE LIKE '$".zip."%'
  AND CITY LIKE '$".city."%' ";