SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with MySQL SELECT Statement

    Hello,

    I checked mysql.com and cannot find any assistance for this:

    I am doing a select statement where a field equals A or B

    Here is an example:

    SELECT bleh FROM table WHERE field = 'A' || 'B';


    Is that the correct way to co an or in a SELECT statement? If not....can someone help?

    Thanks!

    Jim

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    select bleh from table where field = a OR field = b
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    SitePoint Addict EvilDoppler's Avatar
    Join Date
    Dec 2001
    Location
    Perth, Australia
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    don't use php within your sql statements

    the error there is the || part..don't use that within the sql query.

    use:

    Code:
    SELECT bleh
    FROM table
    WHERE field='A' OR field='B'
    and not:

    Code:
    SELECT bleh
    FROM table
    WHERE field='A' || 'B'
    well that's the correct way of doing it anyways.
    Last edited by EvilDoppler; Jun 7, 2002 at 21:56.
    * Due to the last tax raise our prices has risen
    * - answers w/o thought $1 - answers w/ thought $3
    * - correct answers $10
    * - Dumb stares are still free

  4. #4
    SitePoint Addict EvilDoppler's Avatar
    Join Date
    Dec 2001
    Location
    Perth, Australia
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    urggghh Maelstrom was faster...darn it

    typical
    * Due to the last tax raise our prices has risen
    * - answers w/o thought $1 - answers w/ thought $3
    * - correct answers $10
    * - Dumb stares are still free

  5. #5
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah but at least you explained it. I just wrote out the answer. ...
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •