mySQL contains function?

Thread Solved

Join Date: Jan 2009
Posts: 11
Reputation: LTT is an unknown quantity at this point 
Solved Threads: 0
LTT LTT is offline Offline
Newbie Poster

mySQL contains function?

 
0
  #1
Mar 5th, 2009
Ive been looking around and havent been able to find anything like this yet.. I am new to mySQL.

Im looking for a function like the "where" function of a query string.. but insted of it being exact i would like to select "where" datafield "contains" text..


example..

item is listed under multiple states
DB
id=1 name=apple state=FL, WI, CA
id=2 name=orange state=FL

when displaying results i would like to have apple come up when i select any of the states that it is listed under..

any questions?

Thanks,
-LTT
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,319
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 161
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: mySQL contains function?

 
0
  #2
Mar 5th, 2009
  1. SELECT name WHERE state LIKE '%s', $post['state']
  1. mysql_query(sprintf("select name where state like '%s', $post['state'] "));
probably better if you take the commas out of your state tables
wa fl az mi
instead of
wa, fl, az, mi,
many schema give commas a meaning, and cannot be sure where the data will be interpreted and parsed
the space character is a sufficient divider

  1. %s , $post['state'] could be written as
  2. $post['state']
  3. replaceable parameters that I need to know which ones are NUMERIC / TEXT / BLOB to debug, sql %s IS literal TEXT
Last edited by almostbob; Mar 5th, 2009 at 2:54 pm.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: mySQL contains function?

 
0
  #3
Mar 5th, 2009
@almostbob : Rather than posting the exact queries as answer, why not just mention that MySQL contains something like 'LIKE' and then maybe point him towards the documentation page for the same and then let him do the further tasks, such as the syntax botheration for MySQL, PHP etc. Wouldn't the OP learn more things with this approach ?
Last edited by verruckt24; Mar 5th, 2009 at 2:52 pm.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,319
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 161
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: mySQL contains function?

 
0
  #4
Mar 5th, 2009
most do not want to be told
rtfm
its easier for me its just another line of code, that I have in memory, references I have to waste my time looking up
Last edited by almostbob; Mar 5th, 2009 at 3:11 pm.
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: mySQL contains function?

 
0
  #5
Mar 5th, 2009
most do not want to be told - rtfm
Then such people aren't worthy of telling anything at all. Because this community attempts to nurture an environment that makes people learn while helping them. Giving away readymade answers just because someone would not like you telling him "go-read-the-manual", isn't the right approach.

And if you feel that your time is wasted, siting people references from which they can learn, then isn't not posting a good idea to consider ?
Last edited by verruckt24; Mar 5th, 2009 at 3:18 pm.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 83
Reputation: ahmksssv is an unknown quantity at this point 
Solved Threads: 7
ahmksssv ahmksssv is offline Offline
Junior Poster in Training

Re: mySQL contains function?

 
-1
  #6
Mar 7th, 2009
Originally Posted by verruckt24 View Post
Then such people aren't worthy of telling anything at all. Because this community attempts to nurture an environment that makes people learn while helping them. Giving away readymade answers just because someone would not like you telling him "go-read-the-manual", isn't the right approach.

And if you feel that your time is wasted, siting people references from which they can learn, then isn't not posting a good idea to consider ?
@verruckt24 :hi..if anybody post new thread in forums means, its urgent to them...i think pointing to some referance manual is waste of time....Learning depends on their own interest..no body can force them...ok coool....enjoy & learn something by using this forumm..
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,319
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 161
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: mySQL contains function?

 
0
  #7
Mar 7th, 2009
Verruckt
the final arbitration of all takes up so much of your time.
It must be difficult to be you.
Last edited by almostbob; Mar 7th, 2009 at 9:21 am. Reason: Don't like people
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: mySQL contains function?

 
0
  #8
Mar 7th, 2009
Originally Posted by almostbob View Post
Verruckt
the final arbitration of all takes up so much of your time.
It must be difficult to be you.
Hmm.. It's quite easy, I guess, to just retaliate with the first possible means than admitting your mistake. And however difficult it might seem to you, I like to suggest a few good things to people when I see them going wrong.

hi..if anybody post new thread in forums means, its urgent to them...i think pointing to some referance manual is waste of time....Learning depends on their own interest..no body can force them...ok coool....enjoy & learn something by using this forumm..
We are not here to solve people's problem on an urgent basis. If you can understand this is not a 24x7 support site. Go read the forum rules if you want to. And I am sure you might feel reference manuals siting are waste of time because people like you are so very ready to gulp down on readymade food. If the OP doesn't want to learn we won't help him thats all, thats the culture over here, which you might not know well just because you haven't stayed here that long. We cannot force this on the OP but we can certainly opt not to help such blood sucking leeches.
Last edited by verruckt24; Mar 7th, 2009 at 9:53 am.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 1
Reputation: jacobposey is an unknown quantity at this point 
Solved Threads: 0
jacobposey jacobposey is offline Offline
Newbie Poster

Re: mySQL contains function?

 
0
  #9
Aug 19th, 2009
Thank you for posting the examples. I looked at the manual and did not understand it. I like forums where people post their own examples and not just refer to "manuals" because it helps me learn more. Thanks for your help.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,319
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 161
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: mySQL contains function?

 
1
  #10
Aug 19th, 2009
Originally Posted by jacobposey View Post
Thank you for posting the examples. I looked at the manual and did not understand it. I like forums where people post their own examples and not just refer to "manuals" because it helps me learn more. Thanks for your help.
Glad it all helped, examples stick in my mind better too
Failure is not an option It's included free
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC