Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 27-03-2009
Member
 
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?
Reply With Quote
  #2  
Old 27-03-2009
Member
 
Join Date: May 2008
Posts: 2,383
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 .
Reply With Quote
  #3  
Old 27-03-2009
Member
 
Join Date: May 2008
Posts: 2,293
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.
Reply With Quote
  #4  
Old 27-03-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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)
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "MySQL IF ELSE in Query"
Thread Thread Starter Forum Replies Last Post
MySQL query in a query Rail racer Software Development 3 21-07-2009 07:06 PM
Turn on MySQL query cache to speed up query performance DMA2Superman Software Development 3 07-07-2009 10:26 AM
Use variables in a MySQL query Chrisch Software Development 3 25-04-2009 12:11 PM
MySQL Query Cache Ryder Software Development 3 16-04-2009 03:05 PM
MySQL Query Analyzer Jesse Bas Software Development 1 25-11-2008 07:21 PM


All times are GMT +5.5. The time now is 01:11 PM.