user24529
user24529

Reputation: 155

What does the trim function mean in this context?

Database I'm using: https://uploadfiles.io/72wph

select acnum, field.fieldnum, title, descrip

from field, interest

where field.fieldnum=interest.fieldnum and trim(ID) like 'B.1._';

What will the output be from the above query?

Does trim(ID) like 'B.1._' mean that it will only select items from B.1._ column?

Upvotes: 2

Views: 306

Answers (2)

srp
srp

Reputation: 585

trim removes spaces at the beginning and end. "_" would allow representing any character. Hence query select any row that starts with "B.1."

 For eg. 
'B.1.0' 
'B.1.9'
'B.1.A'
'B.1.Z'

etc

Optional Wildcard characters allowed in like are % (percent) and _ (underscore). A % matches any string with zero or more characters. An _ matches any single character.

Upvotes: 3

yowaiOtoko
yowaiOtoko

Reputation: 19

I don't know about the DB you are using but trim usually remove spaces around the argument you give to it. The ID is trimmed to be sure to compare the ID without any white-space around it.

About your second question, Only the ROWS with an ID like 'B.1.' will be selected.

SQL like

SQL WHERE

Upvotes: 1

Related Questions