Results 1 to 4 of 4

Thread: MySQL IF ELSE in Query

  1. #1
    Join Date
    Jan 2009
    Posts
    65

    MySQL IF ELSE in Query

    MYSQL:

    I have receiver _removed column and a column receiver _removed

    If both are 1 then there is a DELETE query executed. Otherwise, an UPDATE query is executed.

    I would just not be looking to php or both on 1 or not, I want mysql to arrange this. So this is about what it should be:

    IIF (receiver_removed = 1 & & sender_removed= 1) THEN DELETE FROM table ELSEIFF (* and here the update query *)

    Who can help me to make a valid mysql query them?

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: MySQL IF ELSE in Query

    I can say 1 thing: you can with (my) SQL (as far as I know) are not both an UPDATE and DELETE query do, though you use only 1 of 2 by a check, go to your PHP therefore need .

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Re: MySQL IF ELSE in Query

    This can happen. With SQL you can write triggers. You can write a trigger on the SQL DELETE statement to delete each one also update under certain conditions.

    However, not all DBMS systems rather advanced feature of SQL you will need to search or MYSQL supports it.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: MySQL IF ELSE in Query

    Triggers are available from MySQL 5.

    You could use a stored procedure or stored function.

    You can simply delete a run and if affected rows == 0 an update. (Or vice versa)

Similar Threads

  1. MySQL query in a query
    By Rail racer in forum Software Development
    Replies: 3
    Last Post: 21-07-2009, 07:06 PM
  2. Turn on MySQL query cache to speed up query performance
    By DMA2Superman in forum Software Development
    Replies: 3
    Last Post: 07-07-2009, 10:26 AM
  3. Use variables in a MySQL query
    By Chrisch in forum Software Development
    Replies: 3
    Last Post: 25-04-2009, 12:11 PM
  4. MySQL Query Cache
    By Ryder in forum Software Development
    Replies: 3
    Last Post: 16-04-2009, 03:05 PM
  5. MySQL Query Analyzer
    By Jesse Bas in forum Software Development
    Replies: 1
    Last Post: 25-11-2008, 07:21 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,560,611.44787 seconds with 17 queries