MySQL Querying Problems

Troncoso

VIP Member
My issue is that I have a table called hardware, and in it there are 2 fields: partid (unsigned int) and serial(varchar). Then I have this specific entry:

Code:
+--------+----------------+
| partid | serial         |
+--------+----------------+
|  60527 |  TN5A151580069 |
+--------+----------------+

But, I can't search for it by its serial number. This is exactly what I try and its result:

Code:
mysql> select partid, serial from hardware where serial='TN5A151580069';
Empty set (0.02 sec)

BUT, I can find it using the partid, as so:

Code:
mysql> select partid, serial from hardware where partid=60527;
+--------+----------------+
| partid | serial         |
+--------+----------------+
|  60527 |  TN5A151580069 |
+--------+----------------+
1 row in set (0.00 sec)

Can anyone see where I'm making a mistake? I have to believe it's an issue with MySQL. I have thousands of serial numbers in my database, and I'm able to get anyone of them through this method.

This issue is with this particular serial number. Any other entry I can find by searching its serial number except this entry.
 
After re-typing the same command several times and it working fine for every serial number but just that one, I don't feel like it's a trailing space..
 
After reading your post again, I realize I misunderstood what you were talking about. The problem turned out to be leading spaces. I dismissed trailing spaces as the php code that places it in the database trims them from the end. Then on a whim, I tried searching the serial number with a space at the beginning and that turned out to be the problem.

Thanks for the suggestion!
 
Back
Top