我被賦予了MySQL查詢:這是在PHP中使用MySQL @variables的正確方法嗎?
SET @COD_PAIS = 3, @ID_CARTERA = 8;
SELECT
C.DES_PERMADURACION AS Item
, B.POR_MADURACION AS Percentage_Distribution
FROM dficha_mes A
JOIN det_maduraciones B
ON (A.ID_FICHA_MES = B.ID_FICHA_MES)
JOIN mpermaduraciones C
ON (B.ID_PERMADURACION = C.ID_PERMADURACION)
WHERE A.ID_CARTERA = @ID_CARTERA
AND A.COD_PAIS = @COD_PAIS
AND B.F_CORTE = (
SELECT
F_ULT_CIERRE_MENSUAL
FROM mpaises
WHERE COD_PAIS = @COD_PAIS);
表在西班牙的行和列。
當我運行使用此查詢PHP的mysql_query()
,我得到以下錯誤:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT
C.DES_PERMADURACION AS Item
, B.POR_MADURACION AS Percentage_Distrib' at line 2
但是這個查詢從MySQL工作臺,甚至SQLyog的完美運行。
任何指針?
非常感謝再次提醒我這件事。我將把代碼庫移動到PDO;只是遺留代碼有上述問題。我很快就會遷徙。謝謝。 –