0

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.


thanks

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by diafol
1

Why don't you try php code.

<?
	$temp = explode('_', $option);
	unset($temp[count($temp)]);
	$option = implode('_', $temp);	
?>
1

Here is your query.

SELECT name,SUBSTRING(name,1,LOCATE('_',name)-1) FROM `student`
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.