Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 693875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:47:55+00:00 2026-05-14T02:47:55+00:00

What I am trying to do here is: IF the records in table todo

  • 0

What I am trying to do here is: IF the records in table todo as identified in $done have a value in the column recurinterval then THEN reset date_scheduled column ELSE just set status_id column to 6 for those records.

This is the error I get from mysql_error() …

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘CASE recurinterval != 0 AND recurinterval IS NOT NULL THEN SET date_sche’ at line 2

How can I make this statement work?

UPDATE todo 
CASE recurinterval != 0 AND recurinterval IS NOT NULL THEN
SET date_scheduled = CASE recurunit
WHEN 'DAY' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval DAY)
WHEN 'WEEK' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval WEEK)
WHEN 'MONTH' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval MONTH)
WHEN 'YEAR' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval YEAR)
END
WHERE todo_id IN ($done) 
ELSE 
SET status_id = 6 WHERE todo_id IN ($done)
END

The following mySQL statement worked just fine before I revised like above.

UPDATE todo 
SET date_scheduled = CASE recurunit
WHEN 'DAY' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval DAY)
WHEN 'WEEK' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval WEEK)
WHEN 'MONTH' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval MONTH)
WHEN 'YEAR' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval YEAR)
END
WHERE todo_id IN ($done) 
AND recurinterval != 0 
AND recurinterval IS NOT NULL
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:47:56+00:00Added an answer on May 14, 2026 at 2:47 am

    The thing is that you’re trying to do something that afaik is impossible to do using just one query. You want to update 1 of 2 columns based on the value of your recurinterval field. So basically you should split it up into 2 queries, the first one will be the one you had ie.

    UPDATE todo 
    SET date_scheduled = CASE recurunit
    WHEN 'DAY' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval DAY)
    WHEN 'WEEK' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval WEEK)
    WHEN 'MONTH' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval MONTH)
    WHEN 'YEAR' THEN DATE_ADD(date_scheduled, INTERVAL recurinterval YEAR)
    END
    WHERE todo_id IN ($done) 
    AND recurinterval != 0 
    AND recurinterval IS NOT NULL
    

    And the second one will be for the other rows :

    UPDATE todo 
    SET status_id = 6
    WHERE todo_id IN ($done) 
    AND (recurinterval = 0 
    OR recurinterval IS NULL)
    

    If you run these queries (most likely you’ll want to run them inside a transaction so you can rollback the changes if an error occurs during one of the queries) you should get the result you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a modest-sized table, 277k records at the moment, which I am trying
Here is the problem I am trying to solve. I have a table where
I am trying to update records with a image button. here is my code:
I have a bunch of divs I'm trying to organize here. The ones I'm
To get half of MySQL table records here is what I'm using: $numRows=mysql_num_rows(mysql_query(SELECT *
Here is my problem (I'm using SQL Server) I have a table of Students
I have a table which has records that contain a persons information and a
I have a bunch of records in a table variable like so: Id ProductId
I'm trying to insert over 100,000 records into an Oracle 9i table with no
I have a MySQL database table containing information about places. I'm trying to fetch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.