1
I am facing a problem, in which I have a table in the BD and it contains the data. However when I do the SELECT
, some data it returns and others not.
For example:
On the table Codigos
i have the following data.
|idEquipamento|idCodigo|
| 1 | 123 |
| 2 | abc123 |
And when I do the select
one returns result and another does not:
"SELECT idEquipamento, idCodigo FROM Codigos WHERE idCodigo = 123";
Returns result!
"SELECT idEquipamento, cdCodigo FROM Codigos WHERE idCodigo = 'abc123'";
It does not return any record, as if it did not exist. But when I open the table the data is there, I can edit and everything!
Note: I am doing the SELECT
by phpMyAdmin himself!
the
idCodigo
is a varchar or int? see that the fields you search for in the query are not in the question table, seeCodigo
andcdCodigo
.– rray
Sorry I misspelled the question but the fields of Where in the case are: WHERE idCodigo = 123; and WHERE idCodigo = 'abc123'; Yes they are VARCHAR!
– JonatasM
@Jonatasm If you wrote something wrong, edit the question to avoid confusing the other users who answer.
– Victor Stafusa
Since varchars are, can be have been recorded with space of a
trim()
to ensure and remember to use simple quotes in the values.– rray
What a
SELECT * FROM eq_Codigos
returns? Why do you haveCodigos
andeq_Codigos
? What is the difference between these two tables?– Victor Stafusa
Sorry was correcting the question because, the two select are in the same table, it simply returns: Mysql did not return any record. (The consultation took 0.0094 seconds.)
– JonatasM
To remove the doubt you could take the create from your table and some Inserts and test in sqlfiddle there put the link here, this will eliminate the environment problem if it exists.
– rray
Dude I don’t know what sqlfiddle is and nor how us-Lo! I’ll give a search on this!
– JonatasM
In the second consultation is
cdCodigo
oridCodigo
?– Victor Stafusa
What is the name of your database?
– Victor Stafusa
do select without Where copy the test you and user it in Where the way it is returning and see what’s strange.
– Marco Souza