Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Mar 2007
    Posts
    212

    Unanswered: How to use the LIKE operator on a table column

    hi,

    How do you use the LIKE operator on a table column using a wildcard?

    e.g. Select * from tbl_employees WHERE 'Permanent' LIKE emptype;

    emptype is a column name of type varchar but i want to add a wildcard to it like the following example:

    Select * from tbl_employees WHERE emptype LIKE '%Permanent%';

    Dont ask me why i want to do it like the first example - its just some wierd thing am trying to do!

    The first example does work but cant seem to find the syntax if there is one to add a wildcard to the tbl column part.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by ozzii
    ...add a wildcard to the tbl column part.
    Code:
    ... LIKE '%' + emptype + '%'
    I think... Maybe... Perhaps
    George
    Home | Blog

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    george, mysql does not use the plus sign for concatenation

    try to keep up, man
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by ozzii
    Dont ask me why i want to do it like the first example - its just some wierd thing am trying to do!
    okay, i won't ask

    but perhaps you might like to show us a few sample rows of data, and then show what the query should return
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Oooh apologies!
    What be thine concatenator?
    George
    Home | Blog

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by georgev
    Oooh apologies!
    What be thine concatenator?
    where be thy fine manual?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    [beam]I don't have one[/beam]
    I don't have access to a MySQL database - I only know some theory, not practice
    I suppose I could go look it up - but it'd probably be more beneficial for the OP to do so
    George
    Home | Blog

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the fine manual is located on the fine mysql web site

    e.g. http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

    you should really download and start practicing

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Should being the operative word
    The company I work for hardly uses it ~ I think it might just be our external site that has a tiny little MySQL db somewhere.
    I guess I use this as my learning resource I try chip in a few cents here and there!
    George
    Home | Blog

  10. #10
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    your company has nothing to do with what you have on your home computer

    and yes, i said "should", not "could" -- it's a rather more forceful suggestion

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  11. #11
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    The website link doesn't want to work - keeps timing out...
    Silly question time: Where can I get a copy of MySQL that I can use on my home PC? In fact, I should probably start a newbie thread for this...
    George
    Home | Blog

  12. #12
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by georgev
    The website link doesn't want to work - keeps timing out...
    check your corporate firewall, mebbe dey don wan you skivin'...
    Quote Originally Posted by georgev
    Silly question time: Where can I get a copy of MySQL that I can use on my home PC?
    on the mysql.com web site!!
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  13. #13
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    You make me laugh Rudy
    And yeah, I thought it'd be something simple like that MySQL is the free one, right? It'll work on XP Pro and XP Home / do I need IIS etc...

    im askin cos i cnt b bothrd lukin it up myself.

    Ach, I'll give the site a read later if I got time
    George
    Home | Blog

  14. #14
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    IIS is used for web publishing, so no, you don't need it
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  15. #15
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    *slaps forehead*
    It's one of those days again - I'm all giddy - apologies
    George
    Home | Blog

Posting Permissions

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