Results 1 to 3 of 3

Thread: Seeing if MySQL field Contains Digit

  1. #1
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755

    Seeing if MySQL field Contains Digit

    Hi guys,

    I think this has an easy solution but I can't figure it out anyway!

    I want to write a query which sees if a field contains a certain number number. The fields are made up in the format like "1 3 4 5", so I want to be able to make a query that will check if a number is in that field. Get me?

    Could anyone help?

    Thanks,
    Mike
    Don't you just love free internet games ?

  2. #2
    Future AstonMartin driver r2d2's Avatar
    Join Date
    Dec 2003
    Location
    UK
    Posts
    1,608
    Something like this: http://dev.mysql.com/doc/refman/5.0/...xt-search.html ?

    So you would do :
    Code:
    SELECT fields FROM the_table WHERE MATCH (number_field) AGAINST ('1');
    I think this is what you want? The field you are searching is text right?

    Remember to set the field to FULLTEXT when doing this!

    That was from a quick search, I think I have used this in the past:

    Code:
    SELECT fields FROM the_table WHERE number_field LIKE '%1%';

  3. #3
    Registered Mike's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    2,755
    I tried the second version and that worked fine, cheers r2
    Don't you just love free internet games ?

Similar Threads

  1. Replies: 0
    Last Post: 08-30-2005, 03:59 PM
  2. Replies: 1
    Last Post: 08-25-2005, 02:56 AM
  3. Clear my misunderstanding: 1 MySQL database for many programs?
    By iKwak in forum Website Programming & Databases
    Replies: 4
    Last Post: 08-21-2005, 10:40 AM
  4. MYSQL question - size of field
    By Blue Cat Buxton in forum Website Programming & Databases
    Replies: 5
    Last Post: 03-03-2005, 05:21 AM
  5. changing a field type in mysql
    By eMEraLdwPn in forum Website Programming & Databases
    Replies: 2
    Last Post: 02-06-2004, 10:13 PM

Bookmarks

Posting Permissions

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