3

I'm working with this table:

mysql> describe dispositivos;
+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| sn        | varchar(25) | NO   | PRI | NULL    |       |
| device_id | varchar(25) | YES  |     | NULL    |       |
| ip_adress | varchar(25) | YES  |     | NULL    |       |
+-----------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

I've noticed that when I type a query like this:

mysql> select * from dispositivos WHERE sn = "SAL1027TVGH";
+-------------+---------------+------------------+
| sn          | device_id     | ip_adress        |
+-------------+---------------+------------------+
| SAL1027TVGH |  CU_DGIE_6509 |  148.228.110.254 |
+-------------+---------------+------------------+
1 row in set (0.00 sec)

everything goes fine, but if I search by any other field, the query is not working.

mysql> select * from dispositivos WHERE ip_adress ="148.228.110.254";
Empty set (0.00 sec)

mysql> select * from dispositivos WHERE device_id ="CU_DGIE_6509";
Empty set (0.00 sec)

Do you know why this is happening?

there are other tables, but the problem just affect this one, it is being filled automatically with LOAD DATA LOCAL INFILE.

thanks.

1
  • 1
    Judging by the alignment of your column names and data, it looks like you have a space at the start of both fields. Commented May 18, 2017 at 7:13

1 Answer 1

5

Look at the output of your select statement: it seems you have a leading blank in your values.

Not the answer you're looking for? Browse other questions tagged or ask your own question.