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 > How to use the LIKE operator on a table column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-29-07, 08:23
ozzii ozzii is offline
Registered User
 
Join Date: Mar 2007
Posts: 194
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.
Reply With Quote
  #2 (permalink)  
Old 05-29-07, 08:34
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Quote:
Originally Posted by ozzii
...add a wildcard to the tbl column part.
Code:
... LIKE '%' + emptype + '%'
I think... Maybe... Perhaps
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 05-29-07, 09:23
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
george, mysql does not use the plus sign for concatenation

try to keep up, man
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 05-29-07, 09:23
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 05-29-07, 09:24
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Oooh apologies!
What be thine concatenator?
__________________
George
Twitter | Blog
Reply With Quote
  #6 (permalink)  
Old 05-29-07, 09:33
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by georgev
Oooh apologies!
What be thine concatenator?
where be thy fine manual?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 05-29-07, 09:35
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
[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
Twitter | Blog
Reply With Quote
  #8 (permalink)  
Old 05-29-07, 09:44
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 05-29-07, 09:52
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #10 (permalink)  
Old 05-29-07, 09:54
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #11 (permalink)  
Old 05-29-07, 10:18
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #12 (permalink)  
Old 05-29-07, 10:28
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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!!
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #13 (permalink)  
Old 05-29-07, 10:48
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #14 (permalink)  
Old 05-29-07, 10:54
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
IIS is used for web publishing, so no, you don't need it
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #15 (permalink)  
Old 05-29-07, 10:55
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
*slaps forehead*
It's one of those days again - I'm all giddy - apologies
__________________
George
Twitter | Blog
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