Does MySQL support something like an "OR" statement?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Samishii23
    New Member
    • Sep 2009
    • 246

    Does MySQL support something like an "OR" statement?

    I came across something in my code today that made me wonder if theres a way to basicly incorporate two statements into one using something like a "OR" logic.

    Basicly something like this:
    Code:
    SELECT * FROM `table` WHERE `user` = "someUser" OR WHERE `email` = "something@bs.com"
    Don't bite my head off, i'm sure thats not proper MySQL syntax, just trying to get my point across.

    Thanks in advance.
  • NetDynamic
    New Member
    • Feb 2011
    • 27

    #2
    Well other than your quotes being the wrong type that is exactly what the query looks like except the 2nd WHERE

    Here its is::

    SELECT * FROM table WHERE user = 'someUser' OR email = 'something@bs.c om'

    Comment

    • Samishii23
      New Member
      • Sep 2009
      • 246

      #3
      Thanks. And my quotes work fine. Been using them for 2+ years, never had a problem.

      Comment

      • NetDynamic
        New Member
        • Feb 2011
        • 27

        #4
        portability, but w/e

        Comment

        • Samishii23
          New Member
          • Sep 2009
          • 246

          #5
          Portability? What doesn't use those quotes? Is it something in the MySQL config?

          Comment

          • NetDynamic
            New Member
            • Feb 2011
            • 27

            #6
            I know some windows servers will error when using ", just saying.

            Comment

            • Samishii23
              New Member
              • Sep 2009
              • 246

              #7
              Hmm. Thanks for the heads up!

              Comment

              • Turktaeteh
                New Member
                • Feb 2011
                • 2

                #8
                Yes, you could use or in sql syntax. Just cut the second WHERE off and correct the quoting stuff. Like this..

                Code:
                select * from 'table' where user = 'someUser' or email = 'someEmail@yy.com'

                Comment

                Working...