-2

[403 image link by OP]

Above image is of my database table in Mssql server. I want to select the data which only contains arrTransactionColumns from report_keys column.

My query is

select * from table where report_keys like '%arrTransactionColumns%'

but it gives the result which has arrTransactionColumnsHRI too.

Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
user1254261
  • 142
  • 2
  • 3
  • 12
  • 1
    USE equal to operator. Why you are using like operator? – knkarthick24 Nov 25 '14 at 06:09
  • equal to operator will retrieve only those rows where report_key contains arrTransactionColumns..but i want all those row which has arrTransaction in it – user1254261 Nov 25 '14 at 06:13
  • explain what you want exactly – Veera Nov 25 '14 at 06:13
  • i want query like this...Select * from table where if arrTransactionColumns is present if any row of report_keys then show the resluting rows – user1254261 Nov 25 '14 at 06:19
  • is this is what you want : You want all rows having arrTransaction. It must include arrTransactionColumns but avoid arrTransactionColumnsHRI. If the value is 'arrTransactionColu' is it is included or avoided. – Veera Nov 25 '14 at 06:28
  • yes..thats exactly what i want..it should be avoided – user1254261 Nov 25 '14 at 06:30
  • What happen if the value is 'arrTran' and What happen if the value is 'arrTransaction345565' – Veera Nov 25 '14 at 06:40
  • then it should be avoided also – user1254261 Nov 25 '14 at 06:44
  • possible duplicate of [Search for “whole word match” with SQL Server LIKE pattern](http://stackoverflow.com/questions/5444300/search-for-whole-word-match-with-sql-server-like-pattern) – Anik Islam Abhi Nov 25 '14 at 07:03
  • Put table structure. Sqlfiddler with Sample data. and expected answer with examble and all possibilities. Else remove the question. – Veera Nov 25 '14 at 07:23
  • try this link from stack overflow itself. [link](http://stackoverflow.com/questions/5444300/search-for-whole-word-match-with-sql-server-like-pattern) – Shamseer K Dec 16 '15 at 15:50
  • The link to the image of the schema is dead. Don't provide information as image which can be text. – Kalle Richter Mar 12 '18 at 17:31

1 Answers1

0

try use CHARINDEX

 select * 
    from TABLE 
    WHERE CHARINDEX('arrTransactionColumns',report_keys )>0
Dudi Konfino
  • 1,126
  • 2
  • 13
  • 24