SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Insert rows, split by certain number

    Hi,

    On our website i have installed a newsletter add-on.
    All the emailadresses (3000) of the recepients are stored in a table called: jos_jnews_subscribers
    The recepients are identified by a subscriber_id

    There also a table called jos_jnews_listssubscribers.
    In this table are the recepients that are "member" of a certain newsletter.
    The newsletter id's are stored in a column called list_id
    To make a user member of a newsletter, I must connect the subscriber_id to a list_id

    I have this query that dumps all the users of jos_jnews_subscribers, into jos_jnews_listssubscribers:

    Code:
    $connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
    
    mysql_select_db($dbname);
    $sql = "INSERT INTO `jos_jnews_listssubscribers`
    
    SELECT DISTINCT
           
    B.id as list_id,
    A.id as subsriber_id,
    A.subscribe_date as subdate,
    (0) as unsubdate,
    (0) as unsubscribe,
    A.params as params
    	   
    FROM jos_jnews_subscribers A, jos_jnews_lists B
    WHERE B.id = '17'";
    
    $query = mysql_query($sql) or die(mysql_error());
    I would like to have this query adapted, so i splits the rows into chuncks of, lets say, 100 rows.
    So, the first hundred rows must become member of list_id 17,
    The second hundred rows must become member of list_id 18 and so on.

    Can this be done ?
    Some advise or a kick into the right direction would be greatly appreciated !!

    Thanks is advance,
    Mesjoggah.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    a ~lot~ easier done with php code than with sql
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    a ~lot~ easier done with php code than with sql
    Hi,

    Thank you for your reply !
    So, your advise is to use php for this matter ?

    Kind regards,
    Mesjoggah


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •