What are the challenges you face when working across database platforms? Take the survey

Examples of the use of the Simple expression generator

I am a newbie.

Interest in using a simple expression generator to use "data from other columns in the table".

Prefix of a specific column value needs to consist of x number of characters from a column within the same row.

Is it possible using a simple expression generator?

Are their example that demonstrate the ability of a simple expression generator to use "data from other column in the table"?


  • Options
    Yes, you can do this using Python's string slicing functionality. Let's pretend we have a column called MyColumn. We can get a substring by using the MyColumn[start:end] syntax, where start refers to the character we want to start at, and end is the first character after the end of the bit that we're interested in. This is zero-based, so the first character of the string is considered character 0.

    For instance, if you have a column called MyColumn and it had a value abcdefg, the simple expression MyColumn[2:5] would return cde.

    Have a look at this Stack Overflow post for more information about string slicing - http://stackoverflow.com/questions/509211/explain-pythons-slice-notation

    I hope this helps.
    Software Engineer
    Redgate Software
Sign In or Register to comment.