Need help!..I am trying to run my query but it's not work... here is my code. "SELECT * FROM name ORDER BY fname ASC" Sort is not working....but I know the problem, I don't know how to solve. The problem is ....there is a single quote inside the fname like 'Oliver and that's why the ORDER BY is not working ... Any help..
So, what you want it to do is ignore the quote if there's one, right? I guess you need the quote to be there for some reason, otherwise you'd be asking "how do I remove the quote?". Mmm... tricky, I can't think of a solution that's pure SQL, but if you can import the result into Excel or manipulate it with PHP I think there's a way to do it.
mysql> use customer; Database changed mysql> desc cust_name; +-------+----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | | auto_increment | | fname | char(20) | NO | | | | | lname | char(20) | NO | | | | +-------+----------+------+-----+---------+----------------+ 3 rows in set (0.00 sec) mysql> Here is my query: "SELECT fname,lname FROM cust_name ORDER BY fname ASC"
Yes rb3m..I am looking for are way to escape the single quote not remove. I try to sort the result using sort() in PHP but I can't, because I am using while($row = mysql_fetch_array($result)){ echo $row['fname'].' '.$row['lname']; } I am thinking about using this code in PHP to sort the array. $custname = mysql_fetch_array($result); $row = sort($custname); foreach($row as $fname=>$lname){ echo $fname.' '.$lname; } But sorry guys, the thing I am looking for is there any way to escape the single quote in mysql query to make "ORDER BY" work.
harsh789 thanx for the help and it's work ...good job mann and I just want to say thanx to all of you guys for helping me... the answer for my problem is in harsh789 comment...