Reputation: 15
I have a SQL Server database. I want to count number of rows where the id starts from 1112 .
(id is string and its format in data base is nchar(7)
)
I have 20 rows that start from 1112 like 1112000
, 1112001
, 1112002
,....
But when I write this query returns 0!.
SELECT COUNT(*) AS num
FROM table
WHERE (id LIKE '1112*')
Upvotes: 0
Views: 113
Reputation: 138960
You should use %
instead of *
.
SELECT COUNT(*) AS num
FROM table
WHERE (id LIKE '1112%')
Upvotes: 2