Я пытаюсь исправить SQL-запрос для последующего преобразования его в Doctrine2 DQL, поскольку он является частью проекта Symfony2. Это то, что мой DDL имеет:Как исправить значение в PostgreSQL для использования в WHERE с инструкцией LIKE?
CREATE TABLE "nomencladores"."norma" (
"id" int4 NOT NULL,
"comite_tecnico_id" int4,
"numero" VARCHAR (10) COLLATE "default" NOT NULL,
"anno" int4 NOT NULL,
"nombre" VARCHAR (255) COLLATE "default" NOT NULL,
"activo" bool,
CONSTRAINT "norma_pkey" PRIMARY KEY ("id"),
CONSTRAINT "fk_f00cbe8e84edad75" FOREIGN KEY ("comite_tecnico_id") REFERENCES "nomencladores"."comite_tecnico" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
) WITH (OIDS = FALSE);
И я пытаюсь выполнить LIKE запроса, чтобы найти %45%
и я попытался все эти вопросы без успеха:
Один порождено Doctrine2 в DQL
SELECT
n0_.numero AS numero0,
n0_.anno AS anno1,
n0_. ID AS id2,
n0_.nombre AS nombre3,
n0_.activo AS activo4,
n0_.comite_tecnico_id AS comite_tecnico_id5
FROM
nomencladores.norma n0_
WHERE
n0_.anno LIKE %45%;
Попытка бросить значения
SELECT
n0_.numero AS numero0,
n0_.anno AS anno1,
n0_. ID AS id2,
n0_.nombre AS nombre3,
n0_.activo AS activo4,
n0_.comite_tecnico_id AS comite_tecnico_id5
FROM
nomencladores.norma n0_
WHERE
CAST (n0_.anno AS CHAR) LIKE %45%;
SELECT
n0_.numero AS numero0,
n0_.anno AS anno1,
n0_. ID AS id2,
n0_.nombre AS nombre3,
n0_.activo AS activo4,
n0_.comite_tecnico_id AS comite_tecnico_id5
FROM
nomencladores.norma n0_
WHERE
CAST (n0_.anno, "FM9999") LIKE %45%
SELECT
n0_.numero AS numero0,
n0_.anno AS anno1,
n0_. ID AS id2,
n0_.nombre AS nombre3,
n0_.activo AS activo4,
n0_.comite_tecnico_id AS comite_tecnico_id5
FROM
nomencladores.norma n0_
WHERE
to_char(n0_.anno, "FM9999") LIKE %45%
SELECT
n0_.numero AS numero0,
n0_.anno AS anno1,
n0_. ID AS id2,
n0_.nombre AS nombre3,
n0_.activo AS activo4,
n0_.comite_tecnico_id AS comite_tecnico_id5
FROM
nomencladores.norma n0_
WHERE
n0_.anno::text LIKE "%45%"
И никто не работает, что это правильный путь для достижения этой цели на PostgreSQL?