Outer of SQL APPLY

Source: Internet
Author: User

Today write a query SQL, which involves to a bank card binding table (table name: bankbind), I want this table of the Account line field values are split out of provinces, sub-branches,

This account bank field stores values such as "Guangdong Province, Guangdong province branch Jiangmen Branch Enping Sub-branch", "China Merchants Bank", "Beijing eight Li Zhuang branch", "Inner Mongolia Autonomous Region," and so on, the division of words involves some logical judgment, So I customized a table-valued function Getdistrictbybankbranch, the entry parameter is a bank value, return a table, containing the province, sub-branch 2 column of data, of course, a record.

Such as

SELECT * from Getdistrictbybankbranch (' Guangdong Province, Guangdong province branch Jiangmen Branch Enping Sub-branch ')

Return:

Province Branch
Guangdong Province Guangdong province Branch Jiangmen Branch Enping Sub-branch

Now, to all the records of the provinces, branches to find out, remember that there have been similar experience, but can't remember how to write SQL. One of the last teams in the development group gave the scenario, that is, using SQL outer APPLY, which is full sql:

SELECT *
From Bankbind A
OUTER APPLY Getdistrictbybankbranch (a.banksubbranch) b

Another, make a note. The persistence layer of the responsible Project uses EF, which today optimizes the Efdbcontext class's Add method to use the key to get a PO, by DBEntities. Getentitykey (entity), where DBEntities is the name of an entity container class that inherits from DbContext, which is typically specified and created when creating an edmx.

Outer of SQL APPLY

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.