Forum Moderators: open

Message Too Old, No Replies

Problem

         

hakkatil

9:04 pm on Jan 7, 2009 (gmt 0)

10+ Year Member



Hi to all,

I have a simple table like
id company userlogin
1 A 011
2 B 012
.. .. ..

When I use below select statement to retreive the company name

select * FROM `timechangerequest` WHERE `userlogin` = 011

it does not display the company name, but If I use id instead of userlogin in above statement it displays the company.

what am i doing wrong? Do you guys have idea?

LifeinAsia

10:15 pm on Jan 7, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld hakkatil! [webmasterworld.com]

Since I assume that userlogin is a VARCHAR field, you need to put the value in single quotes. Try the following:
SELECT *
FROM timechangerequest
WHERE userlogin = '011'

[edited by: engine at 9:01 am (utc) on Jan. 8, 2009]
[edit reason] fixed code [/edit]

hakkatil

7:09 pm on Jan 8, 2009 (gmt 0)

10+ Year Member



thank you for the answer. I tried that and all possible ways I can think of, but it is not working. If i change the field from varchar to int it works. When I use phpmyadmin it works, but in php it does not work. So, I do not know where I am doing wrong.

LifeinAsia

7:49 pm on Jan 8, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If i change the field from varchar to int it works.

Well, it all depends on how you are passing the data to the query. Remember, the character strings '011' and '11' are NOT identical to a DB- they are 2 completely different character strings.

Please provide the exact field types (e.g., DATE, VARCHAR, etc.) you are using for each field of your table.