2
I have a table called PRODUCT and I need to make a comparison between two columns, the column DATA_INICIAL AND DATA_FINAL, for each row travelled, if the product is not in agreement should enter the value 0
in the column PROD_ATIVO.
Rule: If the initial date is greater than the current date or the final date is less than the present date the product should not be displayed.
Product(Exemplification):
Product name: Danoninho
Product display date: 27/03/2017 to 30/03/2017.
There may be registration problems, so the premise is not necessarily valid. Since no restrictions have been reported, they cannot be assumed
– Jefferson Quesado
I know what it’s like. Employee relapse or bad quality control. But rock.ownar is a smart guy and if you think you should assume you’re right, you’ll add an OR update to start > now(). So it would look like this Update PRODUCT set PROD_ATIVO='0' Where DATA_FINAL < now() or Starting Date > now()
– user60252
Is there a nice way to put constraints to ensure these values between the two columns in Mysql? It’s been a long time since I’ve touched it
– Jefferson Quesado
BETWEEN. About SQL constraints are used to specify the rules for the data in a table. The following restrictions are commonly used in SQL: NOT NULL - UNIQUE - PRIMARY KEY - FOREIGN KEY - CHECK - DEFAULT - INDEX
– user60252
Yeah, I was wondering if you could do something like you do on sql server : http://stackoverflow.com/a/13390565
– Jefferson Quesado
That’s not my area anymore, Sorry!
– user60252
In the final date need to be compared with other fields of another table, example is a table called tb_coupons, how would you do? Update PRODUCT set PROD_ATIVO='0' Where TB_CUPONS.DATA_FINAL < now() or TB_CUPONS.Start_now > now()
– rock.ownar
Here is the problem Leo, the prod_active column is in the products table and comparison should be done in the table tb_coupons column which is the one that has the initial and final dates
– rock.ownar
Yes, misworded question confuses, but I saw in Victor Hartur de Carvalho’s comment that already solved his problem.
– user60252