Jump to content

Search the Community

Showing results for tags 'case when'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hello, I recently started working with PHP and MySQL and I have written a code to insert a variable into a MySQL column and if this column is already filled (Not NULL) that it would then continue on and try to update the next column. Here is my code: $result=mysql_query(" UPDATE user_info SET Amount20 = ( case when ( Amount19 is not null and Amount20 is null ) then ‘$amount’ WHERE Username ='$user' else Amount20 end ) , Amount19 = ( case when ( Amount18 is not null and Amount19 is null ) then ‘$amount’ WHERE Username ='$user' else Amount19 end ) , Amount18 = ( case when ( Amount17 is not null and Amount 18 is null ) then ‘$amount’ WHERE Username ='$user' else Amount18 end ) , Amount17 = ( case when ( Amount16 is not null and Amount17 is null ) then ‘$amount’ WHERE Username ='$user' else Amount17 end ) , Amount16 = ( case when ( Amount15 is not null and Amount16 is null ) then ‘$amount’ WHERE Username ='$user' else Amount16 end ) , Amount15 = ( case when ( Amount14 is not null and Amount15 is null ) then ‘$amount’ WHERE Username ='$user' else Amount15 end ) , Amount14 = ( case when ( Amount13 is not null and Amount14 is null ) then ‘$amount’ WHERE Username ='$user' else Amount14 end ) , Amount13 = ( case when ( Amount12 is not null and Amount13 is null ) then ‘$amount’ WHERE Username ='$user' else Amount13 end ) , Amount12 = ( case when ( Amount11 is not null and Amount12 is null ) then ‘$amount’ WHERE Username ='$user' else Amount12 end ) , Amount11 = ( case when ( Amount10 is not null and Amount11 is null ) then ‘$amount’ WHERE Username ='$user'else Amount11 end ) , Amount10 = ( case when ( Amount9 is not null and Amount10 is null ) then ‘$amount’ WHERE Username ='$user' else Amount10 end ) , Amount9 = ( case when ( Amount8 is not null and Amount9 is null ) then ‘$amount’ WHERE Username ='$user' else Amount9 end ) , Amount8 = ( case when ( Amount7 is not null and Amount8 is null ) then ‘$amount’ WHERE Username ='$user' else Amount8 end ) , Amount7 = ( case when ( Amount6 is not null and Amount7 is null ) then ‘$amount’ WHERE Username ='$user' else Amount7 end ) , Amount6 = ( case when ( Amount5 is not null and Amount6 is null ) then ‘$amount’ WHERE Username ='$user' else Amount6 end ) , Amount5 = ( case when ( Amount4 is not null and Amount5 is null ) then ‘$amount’ WHERE Username ='$user' else Amount5 end ) , Amount4 = ( case when ( Amount3 is not null and Amount4 is null ) then ‘$amount’ WHERE Username ='$user' else Amount4 end ) , Amount3 = ( case when ( Amount2 is not null and Amount3 is null ) then ‘$amount’ WHERE Username ='$user' else Amount3 end ) , Amount2 = ( case when ( Amount1 is not null and Amount2 is null ) then ‘$amount’ WHERE Username ='$user' else Amount2 end ) , Amount1 = ( case when ( Amount1 is null ) then '$amount' else Amount1 WHERE Username ='$user' end ) "); I have no idea what is wrong, any help would be great!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.