Results 1 to 2 of 2

Thread: Need help with IF FUnction in MYSQL

  1. #1
    Join Date
    Feb 2008
    Posts
    1

    Need help with IF FUnction in MYSQL

    Hi,

    Please help me with the below query,

    I know something is wrong with the query

    select name, model, year, price, A.standard, A.optional, A.notes from ABC
    WHERE standard <> NULL
    AND (IF Standard= NULL THEN Optional) OR (IF Optional =NULL THEN notes)
    order by name, model , year DESC

    THANK YOU

  2. #2
    Join Date
    Jul 2008
    Location
    Belgium
    Posts
    17
    Hello


    I hope that the 2 queries below will help you to find your expected query.

    SELECT name, model, year, price, standard, optional, notes
    FROM ABC
    WHERE IFNULL(standard, IFNULL(optional, notes))
    ORDER BY name, model, year DESC

    SELECT name, model, year, price, standard, optional, notes, IFNULL(standard, IFNULL(optional, notes)) AS sta_opt_not
    FROM ABC
    ORDER BY name, model, year DESC


    Greetings
    ld_be

Posting Permissions

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