I have a recordset and a field [description] conataining these values:
Levis 501 Jeans - Blue
Levis 501 Jeans - Red
Levis 501 Jeans - Green
Panasonic TZ7 - Grey
Panasonic TZ7 - Silver
Panasonic TZ7 - Black
I have 3 other fields I must include in the query.
I want to strip off everything after the dash, ending up with just "Levis 501 Jeans" or "Panasonic TZ7"
I also don't want any duplicates in this field; I want to end up with just two records.
Is it possible to do all this in one SQL Query, using REGEXP or do I have to create a PHP array and check for duplicates and use something like this to strip off everything after the dash?:
How would you do it?
Levis 501 Jeans - Blue
Levis 501 Jeans - Red
Levis 501 Jeans - Green
Panasonic TZ7 - Grey
Panasonic TZ7 - Silver
Panasonic TZ7 - Black
I have 3 other fields I must include in the query.
I want to strip off everything after the dash, ending up with just "Levis 501 Jeans" or "Panasonic TZ7"
I also don't want any duplicates in this field; I want to end up with just two records.
Is it possible to do all this in one SQL Query, using REGEXP or do I have to create a PHP array and check for duplicates and use something like this to strip off everything after the dash?:
Code:
if(stripos($row['description'], '-') == true) {
$desc = substr($row['description'], 0, strpos($row['description'],'-'));
}
How would you do it?