Thread: MySQL Selects

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Osoyoos, BC, Canada
    Posts
    3
    Rep Power
    0
    Hello,

    I have an odd problem, when ever I do a select on my table like this:

    SELECT * FROM table_name WHERE LCASE(skills) LIKE "%string1%" OR "%string2%";

    MySQL will return a row only matching "string1" and then stop. Is there a way to make it continue after it finds a match?

    I've looked in the mysql documentation.
    I'm using MySQL version 3.22.34 on win98 and FreeBSD. Any help would much aperciated.
  2. #2
  3. No Profile Picture
    RyanP
    Guest
    Devshed Newbie (0 - 499 posts)
    I don't think that you can imply that the value after the OR should be applied to the previous condition LIKE

    try

    SELECT * FROM table_name WHERE LCASE(skills) LIKE '%string1%' OR LIKE '%string2%';
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Osoyoos, BC, Canada
    Posts
    3
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by RyanP:
    I don't think that you can imply that the value after the OR should be applied to the previous condition LIKE

    try

    SELECT * FROM table_name WHERE LCASE(skills) LIKE '%string1%' OR LIKE '%string2%';
    [/quote]


    Thanks for the quick reply.. but that gave a syntax error at the second LIKE..
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    81
    Rep Power
    14
    You SQL should be:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    SELECT * FROM table_name WHERE LCASE(skills) LIKE '%string1%' OR LCASE(skills) LIKE '%string2%';
    [/code]
    Note the use of single quotes -- standard SQL defines the single quote character to delimit a string, not the double quote. MySQL may accept both, but other DBs are likely to be less forgiving.
  8. #5
  9. No Profile Picture
    RyanP
    Guest
    Devshed Newbie (0 - 499 posts)
    oops!

    thanks for the save chris
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Osoyoos, BC, Canada
    Posts
    3
    Rep Power
    0
    Yes, thanks for the help Chris. That worked perfectlly.

Similar Threads

  1. Mysql problem.
    By Nik in forum MySQL Help
    Replies: 54
    Last Post: December 21st, 2006, 06:02 PM
  2. Does MySql do sub selects?
    By FruitBatInShade in forum MySQL Help
    Replies: 1
    Last Post: January 19th, 2004, 08:52 AM
  3. Upgrade from access to mysql
    By karib1 in forum ASP Programming
    Replies: 7
    Last Post: December 16th, 2003, 12:35 PM
  4. Upgrade from access to mysql
    By karib1 in forum MySQL Help
    Replies: 1
    Last Post: December 16th, 2003, 12:27 AM

IMN logo majestic logo threadwatch logo seochat tools logo