Trying to find character occurrences in table field using SUM???

Reply

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

Trying to find character occurrences in table field using SUM???

 
0
  #1
Jan 13th, 2009
Hi there! Im trying to get a SCORE result for how many times a character is present in a table field.

However, my SQL query only returns a SCORE of 1 if the character is present in the field. Where as I need it to tell me how many are in the table field.

  1. SELECT SUM(if(field-name LIKE "%i%", 1, 0 )) FROM table WHERE id = '1'

How would I return a SCORE for how many occurrences? For example, 7 occurrences, SCORE = 7.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 190
Reputation: mwasif is an unknown quantity at this point 
Solved Threads: 25
mwasif mwasif is offline Offline
Junior Poster

Re: Trying to find character occurrences in table field using SUM???

 
0
  #2
Jan 13th, 2009
Look at this, hopefully this is what you need.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the MySQL Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC