Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    1

    Unanswered: int in where clause

    in mysql i have a query as ... where num='355'. but the results for 355 are also returned if i have where num='355+(*';

    here num is a int field.

    i want it to return 0 records in that case. how do i do that?

  2. #2
    Join Date
    Jul 2004
    Location
    Dundee, Scotland
    Posts
    107
    Interesting... I wouldn't have expected MySQL to work that way. Here are a few options:

    Try casting it as an 'integer' if using MySQL 4.0.2:
    http://dev.mysql.com/doc/mysql/en/Cast_Functions.html

    Use PHP to validate the value before doing the database query:
    http://uk.php.net/manual/en/function.is-int.php

    Use a MySQL/REGEXP query to validate the value first:
    http://dev.mysql.com/doc/mysql/en/Regexp.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •