Multiple left join examples for an Access database

Source: Internet
Author: User

Code:

/// <summary>///Category search Query Selectname/// </summary> Public StaticDataTable Getselectname_fljs (stringTHING_TYPE_ID,stringMEN_ID,stringGANG_ID,stringMU_ID,stringKE_ID,stringshu_id) {StringBuilder SB=NewStringBuilder (string. Format (@"Select SN. Sel_chiname as Chinese name, SN. Sel_engname as English name, SN. Sel_latname as scientific name, SN. THING_ID, SN. Sel_type, SN. THING_SHU_ID, SN. THING_PRO_ID, SN. Thing_area_id from (((((Selectname SN left join Shu s on sn.thing_shu_id=s.shu_id) le         ft join Ke k on s.ke_id=k.ke_id) left join Mu m on m.mu_id=k.mu_id) left join Gang G on g.gang_id=m.gang_id)        Left join men me on me.men_id=g.men_id) left join Thing_type TT on TT.THING_TYPE_ID=ME.THING_TYPE_ID where 1=1")); if(!string. Isnullorwhitespace (thing_type_id)&&int. Parse (thing_type_id)! =common.optionallval) {sb. Append (string. Format (@"and tt.thing_type_id={0}", Strutil.sqlclean (thing_type_id))); }    if(!string. Isnullorwhitespace (men_id)&&int. Parse (men_id)! =common.optionallval) {sb. Append (string. Format (@"and me.men_id={0}", Strutil.sqlclean (men_id))); }    if(!string. Isnullorwhitespace (gang_id)&&int. Parse (gang_id)! =common.optionallval) {sb. Append (string. Format (@"and g.gang_id={0}", Strutil.sqlclean (gang_id))); }    if(!string. Isnullorwhitespace (mu_id)&&int. Parse (mu_id)! =common.optionallval) {sb. Append (string. Format (@"and m.mu_id={0}", Strutil.sqlclean (mu_id))); }    if(!string. Isnullorwhitespace (ke_id)&&int. Parse (ke_id)! =common.optionallval) {sb. Append (string. Format (@"and k.ke_id={0}", Strutil.sqlclean (ke_id))); }    if(!string. Isnullorwhitespace (shu_id)&&int. Parse (shu_id)! =common.optionallval) {sb. Append (string. Format (@"and s.shu_id={0}", Strutil.sqlclean (shu_id))); } sb. Append ("ORDER by SN. Sel_chiname"); returnaccesshelper.datatable (sb.) ToString ());}
View Code

Multiple left join examples for an Access database

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.