Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6736525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:08:22+00:00 2026-05-26T11:08:22+00:00

I have 2 tables , table 1 has a field which contains prefixes for

  • 0

I have 2 tables, table 1 has a field which contains prefixes for companies.

The values retrieved from table 1 need to be used to get records from table 2 (based on the prefixes returned).

I coded below to do a startswith to demo what I need done, however what I need to do is build a dynamic starswith clause.

I know the code below wont compile, just putting it out there to show what I would like to accomplish.

//*   This pulls list of prefixes from Table 1

var xrfPrefixes = from xx in XrfPrefixes
 select new
 {
   xxx.CompanyPrefix
 };

//* Get list of prefixes
string PrefixList = "";
foreach (var xxx in xrfJobPrefix)
{
    PrefixList = PrefixList + xxx.FirmJobPrefix + ",";
}

//* Get back Matching records from table 2
var results = from p in Orders.Where(p => p.OrdCust.StartsWith(PrefixList))
select p;

Sample Data in Table 1 (Customers):

  • Row 1: Customer_Prefix char(50) value = “ab1, ab2”
  • Row 2: Customer_Prefix char(50) value = “xy1”
  • Row 3: Customer_Prefix char(50) value = “xy2”

Sample data in table 2 (orders):

  • row 1: customer_name char(50) value = “ab1filler”
  • row 2: customer_name char(50) value = “ab2filler”
  • row 3: customer_name char(50) value = “ab3filler”
  • row 4: customer_name char(50) value = “xy1filler”
  • row 5: customer_name char(50) value = “xy2filler”
  • row 6: customer_name char(50) value = “xy3filler”

Based on the customer_prefixes in the Customers table, the records from Orders Table returned would be Rows 1,2,4 & 5

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:08:23+00:00Added an answer on May 26, 2026 at 11:08 am
    1. Create a PrefixList. Don’t do it as a list of comma-separated strings, do it as a real List<String>. That means you have to split comma-separated values (using String.Split, for example):

      var prefixList = new List<string>();
      foreach (var xxx in xrfJobPrefix) 
      { 
          prefixList.AddRange(xxx.FirmJobPrefix.Split(',').Select(pre => pre.Trim())); 
      } 
      
    2. After you have a PrefixList, you can do a simple LINQ query as follows:

      var results = from p in orders
                    from pre in prefixList
                    where p.OrdCust.StartsWith(pre)) 
                    select p;
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL Server 2005 table that has a varchar(250) field which contains
I have a database structure that has a Person table which contains fields such
I have requirement like, suppose I have a 'property' table which has 'ListingKey' field
Let's say I have a Customer table which has a PrimaryContactId field and a
Let's say I have an Order table which has a FirstSalesPersonId field and a
i have a project table which has a image_id field and a newsimage_id field.
I have a table in MySQL 4.0 which currently has a year field as
I have a table in SQL Server 2005 which has a date time field.
I have a table with a field which contains strings in my MySQL database.
I have table called FinalForgotten which only contains one field called aname. The field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.