MySQL Query Help

Discussion in 'Programming' started by totoros, Nov 13, 2006.

  1. #1
    Hi,

    I'm not that great with MySQL but I was wondering if it were possible to compare strings with a database column where case doesn't matter.

    For example, I have a string named "DiGiTAL PoInT". And in the database there is a string named "digital POINT".

    How can I run a query that will return that there is a match?

    select * from db where string="DiGiTAL PoInT";

    I think this way looks for the exact string
     
    totoros, Nov 13, 2006 IP
  2. totoros

    totoros Peon

    Messages:
    528
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I did a quick google search and it looks like what i'm looking for is the "LIKE" clause. Google works wonders. How dumb of me. Carry on.
     
    totoros, Nov 13, 2006 IP
  3. Madcow

    Madcow Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you can make string to uppercase by using strtoupper() function in php and select all fields from mysql with using

    select * from table

    and with a while

    you can compare the field from table with uppercaseing it if its the right one that matches with your string that uppercased before its the correct one ...


    PS: If your table has soo many lines it works a bit slow. but about 8000 lines it works perfect.
    PS2: If you need help in coding i may help. Pls ask for help.
     
    Madcow, Nov 15, 2006 IP
  4. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #4
    That's all you need.
     
    SoKickIt, Nov 15, 2006 IP
  5. smallbuzz

    smallbuzz Peon

    Messages:
    125
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    case insensitive:
    select * from db where upper(string)=upper("DiGiTAL PoInT");
     
    smallbuzz, Nov 15, 2006 IP