If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > int in where clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-28-04, 14:37
adkm adkm is offline
Registered User
 
Join Date: Jan 2004
Posts: 1
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?
Reply With Quote
  #2 (permalink)  
Old 07-28-04, 18:59
yellowmarker yellowmarker is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On