i am very new to PHP and MySQL. I am trying to write a php script and i am stucking with the selection of rows from a table
The code that works great is:
$q_pages = $wpdb -> prefix . 'q_pages_table';
$q_kws = $wpdb->prefix . 'q_kws_table';
$sql = 'SELECT a1.post_id, a1.kw_id, a2.kw_name ' +
'FROM ' . $q_pages . ' as a1 ' +
'LEFT JOIN ' . $q_kws . ' as a2 ON (a1.kw_id = a2.id)' +
'WHERE a1.draft_id = 4';
The third command is to select and join columns from variable $q_kws to variable $q_pages if there is a match between kw_id and id in the 2 tables and also when the draft_id = 4
Because of the large number of rows in the $sql variable (3000 rows), i want to break $sql to 3 variables, each variable contains 1000 rows, so that later i can process each variable separately.
Is there any suggestion?
Thank you
1 Answer