Skip to main content
October 7, 2006
Question

Using Wildcards on Integers MySql

  • October 7, 2006
  • 1 reply
  • 1923 views
Hi,

SQL PHP/MySql development.

Since 8.02 I cannot use LIKE '%' on integers.

Specific problem:

On a search form I have a dynamic menu/list. The menu is populated with categories (values are integers, labels the names of the categories).

When submitted everything works fine - showing the records belonging to the selected category of another recordset.

If I add a static option with the value of % (or _) to the dynamic menu for "All Categories" nothing shows up.

Prior to 8.02 this worked.

Does anyone how to get this working?
Thanks.

Tom
This topic has been closed for replies.

1 reply

Inspiring
October 7, 2006
Tom Denmark wrote:
> Since 8.02 I cannot use LIKE '%' on integers.
>
> Does anyone how to get this working?

Yes, select "Text" as the data type instead of "Numeric".

LIKE is a pattern comparison operator that requires a string, and all
strings must be wrapped in quotes. If you select "Text", Dreamweaver
escapes any control characters and wraps the string in quotes before
presenting it to MySQL. If you select "Numeric", Dreamweaver looks for
an integer and presents it to MySQL without quotes. If you use a
wildcard, such as % or _, Dreamweaver suspects a SQL injection attack
and replaces the number with 0.

Although it may seem counter-intuitive, Dreamweaver 8.0.2 is treating
LIKE correctly.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
October 7, 2006
Thank you very much. That solved the issue. - Even if I'm not sure that integers wouldn't query faster than text...
Tom