Page 1 of 1

removing quotes from a database query

Posted: Wed Jan 07, 2004 6:38 am
by hyper_st8
Hi,
Just a short question:

If you are selecting a field from a database, where you are using LEFT() to display only the variables that match that first letter, i.e.

$query = "SELECT names FROM table WHERE LEFT(names, 1) = 'a' ORDER BY names ASC";

But within the database one of the names has quotes arround them, how would you get this to still show up that name when it is being listed?

Thank you in advance!

Re: removing quotes from a database query

Posted: Wed Jan 07, 2004 9:24 am
by delorian
I do not know for sure, but it may works:

Code: Select all

$query = "SELECT names FROM table WHERE LEFT(names, 1) = 'a' OR LEFT(names,2) = '"a' ORDER BY names ASC";

Posted: Wed Jan 07, 2004 10:30 am
by hyper_st8
Cheers for that! It works brilliantly! :D