Reputation: 1932
I want to select all rows, where the column g_folder exists in the beginning of the search word. For example: One element in the table c_groups is '/f1' (in column g_folder). So I want to have only the items, which are in the beginning of the search word:
It should look like: g_folder% is like '/f1/xx';
But I can't put this percent behind a variable. How can I do this?
My statement:
select count(*) from c_groups where g_folder is like '/f1/xx'
Upvotes: 2
Views: 217
Reputation: 65187
If this is SQL Server, you can concatenate your column like so:
SELECT
COUNT(*)
FROM
c_groups
WHERE
'/f1/xx' LIKE (g_folder + '%')
Upvotes: 2