Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8135219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:21:01+00:00 2026-06-06T10:21:01+00:00

What really is the difference between MySQL UNHEX and X when dealing with hexadecimal

  • 0

What really is the difference between MySQL UNHEX and X when dealing with hexadecimal values in a database?

Eg.

SELECT * FROM test WHERE guidCol IN (UNHEX('hexadecimalstring'));

SELECT * FROM test WHERE guidCol IN (X'hexadecimalstring');

Both gives me exact result set. So is there any difference? Performance implications?

Edit: the underlying type of guidCol is binary of course

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:21:02+00:00Added an answer on June 6, 2026 at 10:21 am

    UNHEX() is a function, therefore you can do something like

    SET @var = '41';
    SELECT UNHEX(@var);
    SELECT UNHEX(hex_column) FROM my_table;
    

    X, on the other hand, is the syntax for a hexadecimal litteral. You cannot do this:

    SET @var = '41';
    SELECT X@var; -- error (string litteral expected)
    SELECT X'@var'; -- error (`@` is not a hexadecimal digit)
    SELECT X(@var); -- returns NULL, not too sure about the reason... [edit: but this is probably why you are inserting NULL values]
    SELECT X(hex_column) FROM my_table; -- returns NULL as well
    

    This explains why you always get better performance with X: you are using a language construct instead of a function call. X does not need to evaluate a variable, since it expects a litteral string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I mean whats the difference between mysql and flat file database is it really
I am really struggling with understanding the difference between these two. From my textbook,
Simple question really; is there a difference between these values (and is there a
Is there really a big difference between Eclipse 3.2 and 3.4? I am currently
I'm really trying to understand the difference between OpenID and OAuth? Maybe they're two
Really simple question what is the difference between DESCRIBE and EXPLAIN when using it
Is there really any difference between using If(this) { } Else If(that) { }
What is really the difference between the algorithms remove and remove_if and the member
Is there s significant difference between the two? MySQL is used by YouTube, Google
Is there really any difference between <form method=post action=/Controller/Action></form> and @using (Html.BeginForm(Action,Controller)) {} when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.