Search code examples
mysqlsqlmysql-error-1054

MySQL '/' in column name


The problem is that I need to construct the following SELECT statement:

SELECT c.Animal/Dog, c.Animal/Cat, b.Ecoli
FROM Creatures AS c, Bacteria AS b
WHERE blablabla;

Result:

ERROR 1054 (42S22): Unknown column 'c.Animal' in 'field list'

Before people start to tell me that I should rename the columns, it's not my database. I can't change anything, I just need to get this query to work (if at all possible).


Solution

  • Try

    SELECT `c.Animal/Dog`, `c.Animal/Cat` b.Ecoli
    FROM Creatures AS c, Bacteria AS b
    WHERE blablabla;
    

    EDIT:

    Try once by not using Aliases.

    SELECT `CREATURES`.`ANIMAL/DOG`, `CREATURES`.`ANIMAL/CAT`, `BACTERIA`.`ECOLI` FROM CREATURES, BACTERIA WHERE blablabla;