what will be the output of below queries if $option='name'
where 'name' is a coloumn name of a database table which contains the value "GHTY_bbbb"

1.LOCATE('_', '$option');
2.SUBSTR('$option',0,LOCATE('_', '$option'));

i need to fetch the value before "_" from "GHTY_bbbb".if any error in above query please provide me the correct query.


Why don't you try php code.

	$temp = explode('_', $option);
	$option = implode('_', $temp);	

Here is your query.

SELECT name,SUBSTRING(name,1,LOCATE('_',name)-1) FROM `student`