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

  • SEARCH
  • Home
  • 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 7983597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:00:28+00:00 2026-06-04T11:00:28+00:00

This is a follow up to a previous issue I had posted here .

  • 0

This is a follow up to a previous issue I had posted here.

I created a test table:

CREATE TABLE `my_test_table` (
    `record_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `col1` BINARY(20) NULL DEFAULT NULL,
    `col2` CHAR(40) NULL DEFAULT NULL,
    PRIMARY KEY (`record_id`)
)

Then ran the statement:

INSERT INTO my_test_table (col1, col2) VALUES(sha1('test'), sha1('test') );

The data looks like…

1 0x6139346138666535636362313962613631633463 a94a8fe5ccb19ba61c4c0873d391e987982fbbd3

I’m not sure how I can select against the VARBINARY column. I can select against the CHAR like:

SELECT * FROM my_test_table WHERE col2 = sha1('test');

I’ve tried

SELECT * FROM my_test_table WHERE col1 = hex(sha1('test'));

And other variations but can’t seem to find a solution (if there is one). I need to be able to check to see if a value already exists in the database before I allow a new insert. I was looking at VARBINARY and BINARY based on previous suggestions. Thanks.

  • 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-04T11:00:29+00:00Added an answer on June 4, 2026 at 11:00 am

    I have not read your previous question, but based on the source code in this question, you are only storing the first 20 characters of the sha1 hash in col1, so if you want to select it you should just look for the first 20 characters of the sha1 hash.

    For example:

    SELECT * 
    FROM my_test_table 
    WHERE col1 = left(sha1('test'),20);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related to a previous (unanswered) issue I've had with trying to catch
This is a follow up to a previous question that I had before about
This question is a follow up to a previous question I had I'm trying
This question follows on from a previous question, that has raised a further issue.
This is a follow-up questions on a previous one . Consider this code, which
This is a follow up question to a previous question I asked about calculating
This is a follow up to my previous question: Problem passing parameters via Iframe
This is a follow on to my previous question: JSP / servlet / IE
This is a follow on from my previous question although this is about something
This is a follow-up question related to my previous post . Below is a

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.