Hey, worded the title as best I could.
I have a DISTINCT query, works great but I now need the records to include the record ID. In my table the column is named eciid. Adding eciid as the query is right now simply makes that column a part of the DISTINCT criteria and returns even more records.
I only need one of the ID's from a group of records sharing the same DISTINCT values from one or two columns (that part does not matter). I just thought I would ask for advice on the best approach to do this.
My query is below and I changed the second line to this...
Then after testing I realise why it cannot be done this way.
Considered querying the table for each returned record from this query to get a single ID for a single record that shares the distinct values. Either way I look at this, there is a lot of queries to be performed in a loop of say 10 DISTINCT records.
Thanks in advance for a recommended approach
$records = $wpdb->get_results( 'SELECT
FROM '. $csv['sql']['tablename'] .'
LIMIT '.$number.'',ARRAY_A );