If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Re SQL IF statements

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-28-06, 14:15
macjoubert macjoubert is offline
Registered User
 
Join Date: Oct 2003
Location: Rhodesia
Posts: 28
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).
Reply With Quote
  #2 (permalink)  
Old 03-01-06, 19:52
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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 --

Quote:
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)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-02-06, 15:32
macjoubert macjoubert is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 03-02-06, 15:35
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On