Re: Howto search in SQL for a specific character?
| From: | Ciprian Constantinescu | Date: | Wed, 30 Nov 2005 12:02:18 +0000 |
| Subject: | Re: Howto search in SQL for a specific character? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-226633@lists.php.net to get a copy of this message | ||
The ' character has to be escaped. Try using \'
""Gustav Wiberg"" <gustav@varupiraten.se> wrote in message
news:004d01c5f529$2be63aa0$0300a8c0@BLACKSHADOW...
> Hi
>
> I'm sorry but this didn't work either? If I replaced the ' with for
example
> an a it worked
>
> /G
>
> ----- Original Message -----
> From: "Stephen Johnson" <maillists@thelonecoder.com>
> To: "Gustav Wiberg" <gustav@varupiraten.se>; "PHP General"
> <php-general@lists.php.net>
> Sent: Tuesday, November 29, 2005 10:00 PM
> Subject: Re: [PHP] Howto search in SQL for a specific character?
>
>
> > Try this :
> >
> > $sql = "SELECT nameOfPedigree FROM tbpedigrees WHERE nameOfPedigree
like
> > "'%";
> >
> > The % is a wildcard and will give you the results you want.
> >
> >
> > <?php
> > /*
> >
> > Stephen Johnson c | eh
> > The Lone Coder
> >
> > http://www.ouradoptionblog.com
> > Join our journey of adoption
> >
> > http://www.thelonecoder.com
> > stephen@thelonecoder.com
> >
> > continuing the struggle against bad code
> >
> > */
> > ?>
> >
> >
> >> From: Gustav Wiberg <gustav@varupiraten.se>
> >> Organization: Gustav Wiberg
> >> Reply-To: Gustav Wiberg <gustav@varupiraten.se>
> >> Date: Tue, 29 Nov 2005 21:55:27 +0100
> >> To: PHP General <php-general@lists.php.net>
> >> Subject: [PHP] Howto search in SQL for a specific character?
> >>
> >> Hi there!
> >>
> >> in PHP i Write..
> >>
> >>
> >> $v1 = chr(39); //39 is apostrofe
> >>
> >>
> >> $sql = "SELECT nameOfPedigree FROM tbpedigrees WHERE
> >> SUBSTR(nameOfPedigree,0,1) = $v1";
> >>
> >> Why doesn't this work?
> >>
> >> I want the sql to select all nameOfPedigree - fields where the first
> >> character is apostrofe (')
> >>
> >> /G
> >> http://www.varupiraten.se/
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> >
> >
Attachment: [application/x-pkcs7-signature] smime.p7s
Attachment: [application/x-pkcs7-signature] smime.p7s