0

In MySql is it possible to do something like this in a statement that is to be used in PHP and not in a stored procedure or anything else.

if(select count(*) from reports where empId = 9 and repId = 10 = 0,'Do an insert',' Update the existing row')// Just for example

I know about the INSERT ... ON DUPLICATE KEY UPDATE thing. But I cannot use that.

CREATE TABLE `reports` (
    `genId` INT(11) NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(50) NULL DEFAULT NULL,
    `designation` VARCHAR(50) NULL DEFAULT NULL,
    `empId` INT(11) NULL DEFAULT NULL,
    `repId` INT(11) NULL DEFAULT NULL,
    PRIMARY KEY (`genId`)
)
2
  • 2
    "But I cannot use that." why not? Fix whatever it is that's keeping you from using that. Commented Apr 9, 2014 at 13:29
  • You can use Replace maybe? Commented Apr 9, 2014 at 13:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.