Reputation: 9
Database changed
mysql> select * from userinfo;
+-----------+----------+-----------------------+------------+
| firstname | lastname | username | password |
+-----------+----------+-----------------------+------------+
| asif | kolu | ashufound | 123456 |
| faisal | samad | [email protected] | 123456 |
| kamran | shafat | kamthemaam | kamoos |
| ubaid | mir | [email protected] | qwertasd |
| majid | mir | zsffsa | afdfdsf |
+-----------+----------+-----------------------+------------+
5 rows in set (0.00 sec)
mysql> SELECT * from userinfo WHERE lastname = 'mir';
Empty set (0.10 sec)
mysql> SELECT * from userinfo WHERE lastname='mir';
Empty set (0.00 sec)
what is wrong with this code simple where clause not working?actually problem is in the code for insert i think
Upvotes: 0
Views: 462
Reputation: 908
I see some good answers but in the case that you couldn't update leading or trailing spaces in your entire db for each name, you could write the select a little differently. If it is a space issue, try this.
SELECT * from userinfo WHERE TRIM(lastname) = TRIM('mir')
If that doesn't work, try LIKE
and see if you get results. That could help with debugging.
SELECT * FROM userinfo WHERE lastname LIKE '%mir%'
Upvotes: 0
Reputation: 21
I m usign select Query in this the where clause doesnt working query is
select * from table_t where id = '96'
this query is resulting 0 rows but
when i try
select * from table_t where id like '96'
this query is working fine.
and when i try like with column name like
select id from table_t where id like '96'
returning 0 rows
the id is auto generated primary key not have white spaces
why???? is there any database issue??? this query is working fine on my local machine but when i try it online it is misbehaving.
Thanx.
Upvotes: 1
Reputation: 3072
1- You may have space before or after "mir".
2- You may have special (invisible) characters before or after 'mir' or even between its characters.
To solve this problem, I suggest to do this first:
Update userinfo
set lastname = 'mir'
where (username = '[email protected]') or (username = 'zsffsa')
And then, run this to check:
Select * from userinfo where lastname = 'mir'
Upvotes: 0
Reputation: 37253
your last name in your table may have a space before or after mir
mir
^---^---look and remove spaces from here in your table
Upvotes: 1