PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 12, 2022

[FIXED] mysql LIKE with double percent

 March 12, 2022     mysql, php, sql-like, yii     No comments   

Issue

I just debugging a legacy code and I found a strange part in it. Does anybody has an idea, what does the following mean in the MYSQL string?

full_name LIKE '%%{fullname}%%'

Solution

As in the answer Mihir Dave's comment links to, there's no difference to SQL if you pass %% instead of %. Since a single % matches zero or more characters, then each of the metacharacters in %% would also match zero or more, and ultimately the same string would match one way or another.

But I'd guess your legacy code is pre-Python 2.6 that uses % as a metacharacter in string formatting, and you have to double it like %% to get a single literal % character.

See also:

  • How can I selectively escape percent (%) in Python strings?
  • https://docs.python.org/2.6/library/stdtypes.html#string-formatting-operations


Answered By - Bill Karwin
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing