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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:33:55+00:00 2026-06-17T11:33:55+00:00

There is an article about SQL injection: Abusing MySQL string arithmetic for tiny SQL

  • 0

There is an article about SQL injection: Abusing MySQL string arithmetic for tiny SQL injections

The question is, what is the meaning of select ''-'' ? I try it with MySQL, and it returns:

mysql> select ''-'';
+-------+
| ''-'' |
+-------+
|     0 |
+-------+
1 row in set (0.00 sec)

What happend? What means that 0?

And the result of select '-':

mysql> select '-';
+---+
| - |
+---+
| - |
+---+
1 row in set (0.00 sec)

I am very confused about these result.

  • 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-17T11:33:56+00:00Added an answer on June 17, 2026 at 11:33 am

    You are minus - from one empty string '' to other:

    See following:

    mysql> select '';
    +--+
    |  |
    +--+
    |  |
    +--+
    1 row in set (0.00 sec)  
    
    mysql> select '3'-'2';
    +---------+
    | '3'-'2' |
    +---------+
    |       1 |
    +---------+
    1 row in set (0.00 sec)
    

    But warning if its not a number string:

    mysql> select 'a'-'b';
    +---------+
    | 'a'-'b' |
    +---------+
    |       0 |
    +---------+
    1 row in set, 2 warnings (0.00 sec)    
    

    Two warnings:

    mysql> SHOW WARNINGS LIMIT 2
        -> ;
    +---------+------+---------------------------------------+
    | Level   | Code | Message                               |
    +---------+------+---------------------------------------+
    | Warning | 1292 | Truncated incorrect DOUBLE value: 'a' |
    | Warning | 1292 | Truncated incorrect DOUBLE value: 'b' |
    +---------+------+---------------------------------------+
    2 rows in set (0.00 sec)  
    

    Why no warning for empty string?

    Where as there is no warning for empty string because its(casted something) 0 see below:

    mysql> SELECT 0 = '';
    +--------+
    | 0 = '' |
    +--------+
    |      1 |
    +--------+
    1 row in set (0.00 sec)   
    

    hence by doing ''-'' you are doing 0 - 0

    mysql> SELECT '' - '';
    +---------+
    | '' - '' |
    +---------+
    |       0 |
    +---------+
    1 row in set (0.00 sec)  
    

    To be more clear I am adding following example (I feels will be helpful to you):
    How conversion happen:

    mysql> SELECT '0' = 0
        -> ;
    +---------+
    | '0' = 0 |
    +---------+
    |       1 |
    +---------+
    1 row in set (0.00 sec)  
    

    notice its conversion:

    mysql> SELECT '' = '0'
        -> ;
    +----------+
    | '' = '0' |
    +----------+
    |        0 |
    +----------+
    1 row in set (0.00 sec)  
    

    '' converted into 0, '0' converted into 0 but '' not equals to '0'

    mysql> SELECT '1' = 1
        -> ;
    +---------+
    | '1' = 1 |
    +---------+
    |       1 |
    +---------+
    1 row in set (0.00 sec)
    
    mysql> SELECT '' = 1
        -> ;
    +--------+
    | '' = 1 |
    +--------+
    |      0 |
    +--------+
    1 row in set (0.00 sec) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I read article about SQL injection and there was an example: SELECT *
I was reading an article about Sql injection in the article the author mentioned
There is an article out on www.sqlservercentral.com about unit testing your SQL. The TDD
I know there have been questions in the past about SQL 2005 versus Lucene.NET
There doesn't seem to be any clear info out there about T-SQL and the
is there a way to batch copy certain wikipedia articles(about 10,000) to my own
Walter Bright's article on C++ Compilation talks about these two phrases Conversion to preprocessing
Is there an article somewhere explaining exactly how the route matching works and what
I am new to Liferay , is there any good article available for Creating
There was a recent article that Linux kernel 3.3 has integrated Android as one

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.