使用Text计算mysql行数据

How can I count multiple MySQL table rows using text? currently I am using text(names) instead of numbers as values, I know how to count numbers but I have text with spaces where space is not allowed in MySQL.

my code looks like this.

$q = 'SELECT count(TS) as count FROM TABLE_TEST WHERE  
TS='.$db->qstr(Test Data).' GROUP BY id';

as we all know Space between Test Data is not allowed, how can I search using text?

Thanks a lot.

You need to surround strings with either single quotes or double quotes. Single quotes are better in PHP as they are not parsed for variables.

you can also use this:

    WHERE  TS LIKE '%Test Data%' GROUP BY id