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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:12:44+00:00 2026-05-19T01:12:44+00:00

I recently just fixed a bug in some of my code and was hoping

  • 0

I recently just fixed a bug in some of my code and was hoping someone could explain to me why the bug occurred.

I had a query like this:

SELECT * FROM my_table WHERE my_field=13

Unexpectedly, this was returning rows where my_field was equal to either 13 or 13a. The fix was simple, I changed the query to:

SELECT * FROM my_table WHERE my_field='13'

My question is, is this supposed to be the case? I’ve always thought that to return a similar field, you would use something like:

SELECT * FROM my_table WHERE my_field LIKE '13%'

What is the difference between LIKE + a Wild Card vs an equals operator with no quotes?

  • 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-19T01:12:45+00:00Added an answer on May 19, 2026 at 1:12 am

    This statement returns rows for my_field = '13a':

    SELECT * FROM my_table WHERE my_field=13
    

    Because MySQL performs type conversion from string to number during the comparison, turning '13a' to 13. More on that in this documentation page.

    Adding quotes turns the integer to a string, so MySQL only performs string comparison. Obviously, '13' cannot be equal to '13a'.

    The LIKE clause always performs string comparison (unless either one of the operands is NULL, in which case the result is NULL).

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

Sidebar

Related Questions

I just recently started diving into Real World Haskell and the book provides some
I just recently noticed this behaviour. To put it shortly, it displays the commits
I just recently finished Michael Feathers' book Working Effectively with Legacy Code . It
Just recently I dove into the VideoLAN open source project. This was my first
I recently found and fixed a bug in a site I was working on
In optimising some code recently, we ended up performing what I think is a
I'm recently fooling around with some ajax polling techniques. However, it seems like I
We have recently started using git and had a nasty problem when someone committed
I've recently been writing some code for a research project that I'm working on,
I have recently just created Java project using Eclipse that requires 2 JAR files

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.