Search code examples
databasesql-server-2008grails-2.0grails-controller

SQL Querying Database


I have this following query "select abc from table where val = 1"
The result i got was

 [{abc=5}]

However, I need just the integer value 5 from the result instead of the array[{abc=5}].
Anyone have any idea on how to do this? thanks *My friend told me that I will need to use substring to get just the 5 out from the [{abc=5}], but i have completely no clue on how to work on it. Any help will be appreciated!

*edited


Solution

  • try this:

    Assume the integer value comes between = and } symbols

    select substring(abc,charindex('=',abc)+1,len(abc)-charindex('}',abc))
    


    SQL fiddle demo