Q:

How to correct the division result in this MySQL query?

I have this table:
CREATE TABLE `mytable` (
  `id` int(11) NOT NULL,
  `value` longtext,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

With this data:
id, value
--------------------
'1', '__cccccccc; Myword'
'2', '__ddddddd; Myword'
'3', 'OOO; myword; anotherword'

And this query:
SELECT `mytable`.`value`
     , LENGTH(`mytable`.`value`) 'string length'
     , LENGTH(REPLACE(LOWER(`mytable`.`value`),'; myword','')) 'after replace'
     , LENGTH(`mytable`.`value`) - LENGTH(REPLACE(`mytable`.`value`,'; myword','')) 'after sub'
     , LENGTH(`mytable`.`value`) - LENGTH(REPLACE(`mytable`.`value`,'; myword',''))/8 'after divide'
  FROM mytable 
 WHERE LOWER(`mytable`.`value`) LIKE '%; myword%' 
    OR LOWER(`mytable`.`value`) LIKE '%; myword';

And this result:
# value, string length, after replace, after sub, after divide
'__cccccccc; Myword', '18', '10', '8', '16.7500'
'__ddddddd; Myword', '17', '9', '8', '15.8750'
'OOO; myword; anotherword', '24', '16', '8', '22.0000'

The insert statement:
INSERT INTO `test`.`mytable`
(`id`,
`value`)
VALUES
('1','__cccccccc; Myword'),
('2','__ddddddd; Myword'),
('3','OOO; myword; anotherword');

The problem is the last column result is incorrect. For example, the last column in the first record should be 8/8 which is 1. Why am I getting these results? How to correct them plz with the minimal changes? 
Note: I need to convert the strings to lowercase using LOWER because replace is case sensitive and my values are case sensitive (I need to capture any occurrence of the keyword ; myword whether it contains capital or small letters, I do not care.
EDIT:
The query aims to count the number of times the string ; myword appeared. So I count the length of the field, and subtract it from the length of the field after replacing the keyword I want to count with nothing ''. Then divide the result with the number of characters in the keyword string (8 in my case). 

A:

The source of the problem is that REPLACE is case sensitive. So the select statement should be:
SELECT `mytable`.`value`
     , LENGTH(`mytable`.`value`) 'string length'
     , LENGTH(REPLACE(LOWER(`mytable`.`value`),'; myword','')) 'after replace'
     , (LENGTH(`mytable`.`value`) - LENGTH(REPLACE(LOWER(`mytable`.`value`),'; myword',''))) 'after sub'
     , (LENGTH(`mytable`.`value`) - LENGTH(REPLACE(LOWER(`mytable`.`value`),'; myword','')))/8 'after divide'
FROM mytable 
WHERE LOWER(`mytable`.`value`) LIKE '%; myword%' 
#OR LOWER(`mytable`.`value`) LIKE '%; myword';

You can see I added LOWER() inside each REPLACE() because REPLACE() is case sensitive and you search for keyword with small letters, so you must convert your text to small to capture every occurrence of the keyword despite the letter case.
With this query, you get this result:
# value, string length, after replace, after sub, after divide
'__cccccccc; Myword', '18', '10', '8', '1.0000'
'__ddddddd; Myword', '17', '9', '8', '1.0000'
'OOO; myword; anotherword', '24', '16', '8', '1.0000'

so the last column correctly shows the number of occurrence of the keyword in the value field.

