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 > IF ELSE Statement Help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-01-06, 17:53
piet piet is offline
Registered User
 
Join Date: Feb 2002
Posts: 20
IF ELSE Statement Help

I have the following query that I can't seem to get working. I am using MySQL 5.0. The query will eventually go into a stored procedure but for now I am just trying to get it to work in Query Browser. It has been a while since I have used MySQL and I certainly have not done conditionals.

Any help would be greatly appreciated!

Code:
  DECLARE InputItemID int;
  SET InputItemID = 1;
  IF ISNULL(InputItemID) THEN
    SELECT a.AttributesAutomobileID, a.AttributesAutomobileName
    FROM attributesautomobiles a
    ORDER BY a.AttributesAutomobileName ASC;
  ELSE
    SELECT a.AttributesAutomobileID, a.AttributesAutomobileName, b.AttributesAutomobileID as CheckAutomobileID
    FROM attributesautomobiles a
    LEFT OUTER JOIN itemautomobile b ON b.ItemID = InputItemID
    AND b.AttributesAutomobileID = a.AttributesAutomobileID
    ORDER BY a.AttributesAutomobileName ASC;
  END IF;
Regards,

Piet
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