Friday, February 6, 2015

How to show records in same order where IDs are put into the IN() clause?

 
 
How to show records in same order where IDs are put into the IN() clause? 
 
 
1) SELECT id FROM table1 WHERE ... ORDER BY display_order, name

2) SELECT name, description, ... WHERE id IN ([id's from first])
 
The issue is that the second query does not return the results in the same order 
that the IDs are put into the IN() clause. 
 
Solution :- 

SELECT name, description, ...
FROM ...
WHERE id IN([ids, any order])
ORDER BY FIELD(id, [ids in order])

Monday, February 2, 2015

Is a BLOB converted using the current/default charset in MySQL?


Blob data used MySQL charset which is in my.ini

default-character-set=latin1

Suppose
  1. I have a table with a BLOB field.
  2. The charset of the table is UTF-8.
  3. I connect to the DB and "SET CHARACTER SET utf8".
  4. Then I save binary data into the field.
  5. Then I retrieve the data, and it's not what I saved (corrupt).
Because while retrieving data blob data used mysql default charset set.

Ref :
http://stackoverflow.com/questions/14734812/is-a-blob-converted-using-the-current-default-charset-in-mysql

Create MongoDB service in Windows OS

1) Open Command Prompt 2) Create directory for Database and Logs                    mkdir c:\data\db                     mkdir c:\...