user3303594
user3303594

Reputation: 61

count mysql row data using Text

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.

Upvotes: 0

Views: 73

Answers (2)

echo_Me
echo_Me

Reputation: 37253

you can also use this:

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

Upvotes: 0

Jeff
Jeff

Reputation: 799

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.

Upvotes: 1

Related Questions