tags:

views:

18

answers:

1

I have a table like :

------------------------------
Test_Id           Test_data
(String)          (blob)
------------------------------

I want a query to retrieve all the Test_Id's for a matching Test_data.

To achieve something like : select * from test_table where Test_data = blobObject;

How can we do above ??

A: 

first: theres no such thing as a string in mysql. only char/varchar/text

well you could cast it as char for comparision like this:

select * from test_table where Test_data = CAST( blobObject AS CHAR );

whats probably better is to convert your string to a binary string, but this might not give you the right comparision if you expect string comparision behaviour... well best you have a look at the char functinos here:

http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html

Joe Hopfgartner