Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL get all characters before specific character

Tags:

I have a table where I extract some values, one column values can contain "value1|value2|value3", but I only want to get the characters before the | - "value1".

This is what I tried, but it doesn't work.. What am I doing wrong? Thanks!

$sql = "SELECT * LEFT('Like', LOCATE('|', 'Like')-1) FROM $tablename WHERE Parent = '0' AND Type LIKE 'top' ORDER BY Order ASC";

I want to use this for ALL values, not just one field..