Does anyone know why MySQL Select sometimes does not Work?

1

I'm facing a problem, in which I have a table in the DB and it contains the data. But when I do SELECT , some data it returns and some do not. For example:

In the Codigos table I have the following data.

|idEquipamento|idCodigo|
|      1      |  123   |
|      2      | abc123 |

And when I do select one returns result and another does not:

"SELECT idEquipamento, idCodigo FROM Codigos WHERE idCodigo = 123"; 

Return result!

"SELECT idEquipamento, cdCodigo FROM Codigos WHERE idCodigo = 'abc123'"; 

Does not return any records, as if they did not exist. But when I open the table the data is there, I can edit it and everything!

Note: I'm doing SELECT by phpMyAdmin itself!

    
asked by anonymous 16.09.2016 / 21:55

1 answer

2

Table: Codes (with C )

|idEquipamento|idCodigo|
|      1      |  123   |
|      2      | abc123 |

Test this command:

SELECT idEquipamento, idCodigo FROM Codigos WHERE idCodigo = 'abc123'

It should return the second line. Then test more these 2 commands to see what returns:

SELECT idEquipamento, idCodigo FROM Codigos WHERE idCodigo = '123'

SELECT * FROM Codigos WHERE idCodigo = 'abc123'

Also try with TRIM()

SELECT * FROM Codigos WHERE TRIM(idCodigo) = 'abc123'
    
16.09.2016 / 22:15