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 3990188
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:27:50+00:00 2026-05-20T06:27:50+00:00

Assume that i have two strings like the following. $sa = 12,20,45; $sb =

  • 0

Assume that i have two strings like the following.

$sa = “12,20,45”; $sb = “13,20,50”;

I want to check whether any of the number in sa present in sb with back reference so that i can get those numbers back and do some calculation.

The numbers are nothing but unique id’s in database. So i am checking whether the ids in sa is present in the list of ids in sb.

Besides if it is possible to get all matching and non matching ids then that would be nice.
For this it doesn’t have to be one operation. Multiple operations is fine.(like executing match twice or more).

  1. What i am trying to do is i am creating subscribers and they are assigned to groups.
  2. I create newsletters and will assign to groups.
  3. If i try to assign a newsletter to the same group then i want the group id so that i can exempt that group and assign that newsletter to the rest.
  4. so if group 15,16,17 are already assigned with a newsletter and the next time i am trying to assign group 15,20,21 i want 15 to be exempted and i want the newsletter to be assigned to 20,21.

And… If i could get a mysql example too then that could be nice.

Any type of answer if it could help the please post it.
THX

  • 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-20T06:27:51+00:00Added an answer on May 20, 2026 at 6:27 am

    first of all, this is not a problem you would want to solve with regex. At.all.

    Second, you shouldn’t have a list of Ids as values in your database, especially if you need to look up on them. It’s inefficient and bad database design.

    If you only require to link subscribers to newletters these would be the tables you need, one table per entity and a junction table for joining. I have left out the foreign key constraints.

    CREATE TABLE Subscribers
    (subscriber_id bigint,
    first_name varchar(50),
    ... )
    
    CREATE TABLE Newsletter
    (news_letter_id bigint,
    name varchar(50),
    ... )
    
    CREATE TABLE NewslettersSubscribers [or just "Subscriptions"]
    (news_letter_id bigint,
    subscriber_id bigint,
    payment_type smallint,
    ...[other variables that are specific to this subscription]
    )
    

    If you would rather have your subscribers in a group and each subscriber can be in many groups, it would look like this.

    CREATE TABLE Subscribers
    (subscriber_id bigint,
    first_name varchar(50)
    ... )
    
    
    CREATE TABLE Group
    (group_id bigint,
    group_name varchar(50),
    ... )
    
    CREATE TABLE SubscribersGroups --[or just "Membership"]
    (subscriber_id bigint,
    group_id bigint,
    payment_type smallint,
    --...[other variables that are specific to this membership]
    )
    
    CREATE TABLE Newsletter
    (news_letter_id bigint,
    name varchar(50),
    ... )
    
    CREATE TABLE NewslettersGroups --[or just "SubscriptionGroups"]
    (news_letter_id bigint,
    group_id bigint
    --...[possibly variables that are specific to this subscription group]
    )
    

    Now your actions are rather simple. In your example we have newsletter 1, and we have groups 15, 16, 17, 20 and 21 and possibly other groups. We also have these values in NewslettersGroups

    | news_letter_id | group_id |
    |              1 | 15       |
    |              1 | 16       |
    |              1 | 17       |
    

    Now you want to connect newsletter 1 to 20 and 21 (only you think you need to do 15 as well). So just insert where it’s needed (I’m not 100% sure if this syntax works, I don’t use MySQL, but see this reference)

    INSERT INTO NewslettersGroups VALUES (1,15),(1,20), (1,21)
    ON DUPLICATE KEY UPDATE;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's assume that I have a collection of strings, like so: IList<string> myList =
Assume that I have two arrays as follow: $array1 = array(1, 3, 5); $array2
Let's say we have two objects. Furthermore, let's assume that they really have no
Let's assume I have two gmdistibution models that i obtained using modeldata1=gmdistribution.fit(data1,1); modeldata2=gmdistribution.fit(data2,1); Now
I have a city table that has two columns from_city to_city now lets assume
Assume that we have the following code: class Program { static volatile bool flag1;
Assume that we have two classes public class EntityA { public EntityB EntityB {
I have an array that created 5 objects. Each object has two strings and
Assume that you have two IEnumerbale objects. How we can merge them (in some
I'm trying to create an expression tree dynamicly. Let asume that I have two

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.