I am trying to use the following code alter table Appointment ADD constraint chk_date check( AppointmentDate >= curdate()); However it gives the following error saying that curdate function is …
Category: Questions
Pivot table with multiple aggregate value
I am trying to pivot below table, is that possible? But if I aggregate them by Code, Value A or B will be gone because of it. From Name Code Value Kevin Code1 A Kevin Code1 B Kevin Code2 C Kevin …
SQL left join but only take the specific condition on a column
I have two tables, the first is a table that contains status and the second is contains balance. I want to join those two tables but with only specific status on the first table Sample Data Table 1 +–…
How to add escape $ in Zend framework query
I need to add escape ‘$’ in zend framework. expected query: SELECT * FROM V_HOME_SEARCH sv WHERE sv.NAME LIKE ‘%gar$_%’ ESCAPE ‘$’ I tried this: public function selectData($str){ $select = $this->…
How to make mysql run Delet query automatically
I Have an OTP table and I want to delete data that is older than 5 minutes automatically Then how could I make trigger or procedure for that?
Joining Multiple Tables with different structures?
I have a dataset in SQL with some tables which I need to join them. There is a main table called ‘main_table’ that consists two parameters (id and name) and one of them is the key ‘id’. main_table, …
How can I count total item in an object/record and count only the value = true
obj = {true, false, false , true,…}; This is only one record that I query from database by using Linq The reason is I would like to display Finsished 2 of 7 , that is why I need to count items in a record. Thank you in advance! After I can store numbers in variable, then I would like to
Finding data from same table
My table is : loginid name role 12 abc analyst 12 abc clerk 142 xyz clerk 142 xyz manager 1 yash manager 1 yash ceo 2 aarav president 2 aarav ceo I want to display each login id once and if …
how to ignore the values before and after between the rows in a table
I have a table as like below I have to add a new column to the table as “value_”, which should contains age values for rows between last TRUE i.e row number 4 (highlighted in green color) …
SQL – Compare rows based on date and transpose difference
Scenario: Table ‘HIST’ RID VALUE HIST_DATE 1 V111 2019-01-01 1 V112 2020-02-11 1 V112 2020-03-08 1 V113 2020-04-11 1 V114 2021-03-15 2 V211 2020-04-11 2 V211 2021-03-16 3 V311 2019-05-01 3 …