mysql - regular expression how to match with backreference two mixed type string -


assume have 2 strings following.

$sa = "12,20,45"; $sb = "13,20,50";

i want check whether of number in sa present in sb reference can numbers , calculation.

the numbers nothing unique id's in database. checking whether ids in sa present in list of ids in sb.

besides if possible matching , non matching ids nice. doesn't have 1 operation. multiple operations fine.(like executing match twice or more).

  1. what trying creating subscribers , assigned groups.
  2. i create newsletters , assign groups.
  3. if try assign newsletter same group want group id can exempt group , assign newsletter rest.
  4. so if group 15,16,17 assigned newsletter , next time trying assign group 15,20,21 want 15 exempted , want newsletter assigned 20,21.

and... if mysql example nice.

any type of answer if please post it. thx

first of all, not problem want solve regex. at.all.

second, shouldn't have list of ids values in database, if need on them. it's inefficient , bad database design.

if require link subscribers newletters these tables need, 1 table per entity , junction table joining. have left out 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 "subscriptions"] (news_letter_id bigint, subscriber_id bigint, payment_type smallint, ...[other variables specific subscription] ) 

if rather have subscribers in group , each subscriber can in many groups, 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 "membership"] (subscriber_id bigint, group_id bigint, payment_type smallint, --...[other variables specific membership] )  create table newsletter (news_letter_id bigint, name varchar(50), ... )  create table newslettersgroups --[or "subscriptiongroups"] (news_letter_id bigint, group_id bigint --...[possibly variables specific subscription group] ) 

now actions rather simple. in example have newsletter 1, , have groups 15, 16, 17, 20 , 21 , possibly other groups. have these values in newslettersgroups

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

now want connect newsletter 1 20 , 21 (only think need 15 well). insert it's needed (i'm not 100% sure if syntax works, don't use mysql, see this reference)

insert newslettersgroups values (1,15),(1,20), (1,21) on duplicate key update; 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -