How can I select from table by uuid in mysql

10,851

Solution 1

I don't know if you still need this. But, here's the query.

select Id, CompanyName from table1 where Id = x'e4816509dd01cf1b65e3dc43e2a90a01';

OR

select Id, CompanyName from table1 where Id = 0xe4816509dd01cf1b65e3dc43e2a90a01;

!!! note that the dashes from the uuid were removed

Solution 2

SELECT Id, CompanyName FROM table1 WHERE Id= UNHEX('e4816509-dd01-cf1b-65e3-dc43e2a90a01');

Share:
10,851
Boss Yoon
Author by

Boss Yoon

Updated on June 04, 2022

Comments

  • Boss Yoon
    Boss Yoon almost 2 years

    I want to select some data from database (MySQL) comparing 'Id' Column. And It's type is binary(16) .

    So, I write query like this but It's not work. Empty dataset returned. How Can I fix it?

    select Id, CompanyName from table1 where Id = 'e4816509-dd01-cf1b-65e3-dc43e2a90a01';
    

    Thank you.