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 6893635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:41:00+00:00 2026-05-27T06:41:00+00:00

I have a table like this: CREATE TABLE IF NOT EXISTS `session` ( `id`

  • 0

I have a table like this:

CREATE TABLE IF NOT EXISTS `session` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `token` varchar(32) NOT NULL,
  `profile` varchar(1000) NOT NULL,
  `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=41 ;

and some data in this table:

(38, '395d5feaf28df01aafe0781a7f34acbe', 'a:3:{s:2:"id";s:1:"2";s:8:"username";s:7:"wanmeng";s:12:"created_time";s:19:"2011-11-18 19:37:33";}', '2011-12-03 14:14:35'),
(39, '0e0ca06ed9ad86937f190eb9544ac935', 'a:3:{s:2:"id";s:1:"1";s:8:"username";s:6:"delphi";s:12:"created_time";s:19:"2011-11-18 13:29:40";}', '2011-12-03 14:28:36'),
(31, '3cba76b97cf123009632bdaa5a306385', 'a:3:{s:2:"id";s:1:"1";s:8:"username";s:6:"delphi";s:12:"created_time";s:19:"2011-11-18 13:29:40";}', '2011-12-02 15:50:21'),
(30, 'fa356333dd3ee8f1b18b8bf0a827e34c', 'a:3:{s:2:"id";s:1:"1";s:8:"username";s:6:"delphi";s:12:"created_time";s:19:"2011-11-18 13:29:40";}', '2011-12-01 15:32:47')

When I execute the query: SELECT * FROM session WHERE token = false , I expect no result returned, but the mysql returns the results:

39  0e0ca06ed9ad86937f190eb9544ac935    a:3:{s:2:"id";s:1:"1";s:8:"username";s:6:"delphi";...   2011-12-03 22:28:36
30  fa356333dd3ee8f1b18b8bf0a827e34c    a:3:{s:2:"id";s:1:"1";s:8:"username";s:6:"delphi";...   2011-12-01 23:32:47

It seems like the boolean value ‘false’ can match some varchar, but is there any relation between ‘fa356333dd3ee8f1b18b8bf0a827e34c’ and ‘false’, why is it so?

  • 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-05-27T06:41:00+00:00Added an answer on May 27, 2026 at 6:41 am

    In MYSQL, FALSE is not a boolean value, it’s an integer, more specifically zero. In fact, MySQL does not have boolean column types (it has BOOL and BOOLEAN but they’re mere aliases for TINYINT). So your query is a synonym for:

    SELECT * FROM session WHERE token = 0
    

    Since token is a VARCHAR, MySQL needs to convert your strings to number. Run this query and you’ll get an idea about the rules:

    SELECT
        0 + "0001",
        0 + "123abc",
        0 + "abc123"
    

    As a result, fa356333dd3ee8f1b18b8bf0a827e34c casts to 0 because it starts with a letter, thus the match.

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

Sidebar

Related Questions

I have a testdata like this: DROP TABLE SELECT_PASS; CREATE TABLE SELECT_PASS(ID INT(20),TESTCASE VARCHAR(20),RESULT
I have a database table that looks like this: CREATE TABLE IF NOT EXISTS
I have a mysql table like this (sql): CREATE TABLE IF NOT EXISTS silver_and_pgm
I have a MySQL table like this CREATE TABLE IF NOT EXISTS `vals` (
I have this table CREATE TABLE IF NOT EXISTS `profile_connections` ( `id` int(11) NOT
Say I have a table like so: CREATE TABLE big_table (UUID varchar(32) not null,
I have something like this: create table account ( id int identity(1,1) primary key,
I have two table like below CREATE TABLE IF NOT EXISTS `countries` ( `id`
If I have a table like this: CREATE TABLE sizes ( name ENUM('small', 'medium',
I have a SQL Server 2005 table like this: create table Taxonomy( CategoryId integer

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.