mysql - Multiple Errors for Not Finding Columns and Tables in Database -
i started working mysql last week, , i'm attempting write code check earliest instance of billing record address , mark "new". should identify if account has since been cancelled , mark first instance of cancelled record "new". code compiles, whenever try test inputting address, receive "error code: 1054. unknown column 'billingrecords.address' in 'where clause'" feel i've tried every fix column references under sun (with/without backticks, single quotes, database names, table names, etc.) how should referencing columns in code avoid error? also, since haven't been able test properly, there may few other errors in code. if notice anything, i'd appreciate feedback.
the columns using are: address varchar(145) yes mul null cancel varchar(45) yes null date date yes null
i hope it's alright repost question. have yet code working. original thread here.
code in question
select min(`date`) earliestdate billing.billingrecords `address` = addresstocheck; #determines earliest date of instances of specified address select min(`date`) earliestcanceldate billing.billingrecords `address` = addresstocheck , `cancel` = "cancelled"; #determines earliest date of instances of specified address account has been marked "cancelled" case when `billingrecords`.`address` = addresstocheck , `billingrecords`.`date` = earliestdate set isitnew = "new"; #returns "new" if address matches specified address , date matches earliest date when `billingrecords`.`address` = addresstocheck , `billingrecords`.`date` != earliestdate set isitnew = "old"; #returns "old" if address matches specified address , date not match earliest date else set isitnew = null; end case; case when `billingrecords`.`address` = addresstocheck , `billingrecords`.`date` = earliestcanceldate , `billingrecords`.`cancel` = "cancelled" set isitnewcancel = "new"; #returns "new" if address matches specified address, account marked "cancelled", , date matches earliest cancel date when `billingrecords`.`address` = addresstocheck , `billingrecords`.`date` != earliestcanceldate , `billingrecords`.`cancel` = "cancelled" set isitnewcancel = "old"; #returns "old" if address matches specified address, account marked "cancelled", , date not match earliest date else set isitnewcancel = null; end case;
Comments
Post a Comment