Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    Rhodesia
    Posts
    28

    Unanswered: Re SQL IF statements

    As my response pertains to MYSQL pls find the small correction to the previous posters post:

    Quote Originally Posted by r937

    also, you cannot use the equals sign in a SELECT either
    Sorry but this is not true, you can indeed use an '=' in a select statement

    E.G.
    Select column1= '10' from table;

    will result in a boolean interpretation of column 1 values against '10', in other words, the result set will be 0 (for a no match) or 1 (for a match).

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    that thread was moved to where it belonged in the first place (sql server forum)

    but if you're gonna correct me again here, then i also would like to post my response --

    you are correct but buddy who posted in the mysql forum is almost certainly looking for the sql server effect, to assign a column alias

    it's so rare that i see someone actually using the mysql perversion, er, i mean, version which interprets the equality as a boolean expression, that it escaped my memory

    of course you can do that in mysql, but you shouldn't (you should use CASE instead)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2003
    Location
    Rhodesia
    Posts
    28
    It wasnt meant to criticize but inform, the quantity and quality of reliable MySQL information is very finite and not exhaustive, any tidbit will help others as it has me.
    Apologies if you felt slighted.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    no apology necessary, i have a much thicker skin than that

    i just wanted to make sure the message gets through to anyone else who comes upon this thread later, that using an equality in the SELECT is not a good idea, even if mysql will execute it

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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