Subject Re: [firebird-support] Part of string into JOIN statement
Author Ann W. Harrison
majstoru wrote:
> Hi,
>
> My problem is how to write SELECT statement which will cut first 4
> letters from id from STATUS table (Sample 1010001 -> 001) and join
> USERS table on STATUS table by this these 3 letters (Sample 001)

You (or the designer of the database) have violated one of the
cardinal rules of relational database design. Values are atomic -
in the pre-1903 sense of the word - they are particles of data
that can not be subdivided. Now, maybe you're actually Nils Bohr
and will show the world how to use subatomic data effectively.
Or maybe not.

If you can change the design, split that field into two atomic
fields. If you want, you can create a computed field of the
two values concatenated and use the old field name for the computed
field while using the atomic parts for this join and other operations
on the individual parts. Or, I guess, you could either create two
computed fields that represent the two halves of the combined field -
or make real fields and maintain them with triggers.

Substring is probably the operation you want.


Regards,


Ann