简体   繁体   中英

SQL: Where SO.num = “S”+PICK.num

I'm fairly new to SQL with no formal education, so appreciate your expertise (and patience) as I don't even know what to search for.

I need to run a query that connects two tables. The connectors are SO.num & PICK.num. However, the PICK.num always has a "S" in front, so I'm not sure how to write that out.

As an example: If the SO.num is ABC-123, the PICK.num is SABC-123.

Thanks in advance for your help!

Stephen

You would use string concatenation in the join condition:

select ...  -- enumerate the columns you want the query to return here
from so as s
inner join pick as p on p.num = concat('S', s.num)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM