Search Posts

Category: sql

select the same day each month for the past 2 years or any year

i’m working on recurring payment monthly and i can’t or How do i select the same day each month for the past 2 years using SQL? example : send “23-11-2017” to get all records has been added in the same day or send “31-01-2018” to get all records has been added in the same day but all months don’t have same day “31” , how i can to get all records has been added in […]

Sql – Update sql with subquery

I trying to update mysql data table with subquery . Can i anyone can please guide me . These the code i trying. Update table_name set meta_value = ‘day’ WHERE post_id IN (SELECT post_id FROM table_name WHERE meta_key = ‘_min_date’ AND meta_value=’0′) AND meta_key = ‘_min_date_unit’ Source: Stackoverflow

MYSQL workbench – error 1215: Cannot add foreign key constraint

Now before you flag this as a duplicate, I went through many stack overflow solutions. The names are matching The data types match Both are not null, what could be the problem? This is my code: create database Registration; use Registration; create table Department(DepartmentID varchar(25) NOT NULL, DepartmentName varchar(25), PRIMARY KEY(DepartmentID)); insert into Department(DepartmentID, DepartmentName) values (‘DE1’, ‘Engligh’); insert into Department(DepartmentID, DepartmentName) values (‘DS2’, ‘Science’); insert into Department(DepartmentID, DepartmentName) values (‘DM3’, ‘Math’); create table Course(CourseID […]

Sql query with three conditions

I have a database with a table having content as below : message_number message_type message_chat 0 IN Hi 1 OB Hello 2 IN Help 3 IN Want to find this thing 4 OB Sure 5 OB Please let me know I have written 5 rows since i want to incorporate all possible cases that i want in my query in the example table that i showed. Now in my query output, i want something like […]

How to get minimum date from date fields except null values?

My datatable is likes follows, ID | Date1 | Date2 | Date3 ————————————— 1 | 2017-09-12 | null | 2017-10-11 2 | null | 2017-09-21 | null 3 | 2017-11-01 | null | null 4 | 2017-08-01 | 2017-09-22 | 2017-09-23 I want to get minimum date for each rows from Date1,Date2 and Date3 I tried it from select LEAST(IFNULL(Date1,’9999-12-31′),IFNULL(Date2,’9999-12-31′),IFNULL(Date3,’9999-12-31′)) this way, It works, But I want to know is this the BEST way to […]

How sum QTY by month also and week also and by area also in one query?

//since i am new to dash db i dont know how to use group by to perform three four events in one query i want to group by “QTY” by month,week and area in one query is it possible to do select RETAIL_STORE.STR_NM as STR_NM, RETAIL_STR_SALES_DETAIL.SALE_DATE AS SALE_DATE, monthname(RETAIL_STR_SALES_DETAIL.SALE_DATE) AS MONTHNAME, month(RETAIL_STR_SALES_DETAIL.SALE_DATE) as Monthnumber, WEEK(RETAIL_STR_SALES_DETAIL.SALE_DATE) AS WEEK, DAY(RETAIL_STR_SALES_DETAIL.SALE_DATE) AS DAY_OF_WEEK, RETAIL_STR_SALES_DETAIL.prod_id, RETAIL_STR_SALES_DETAIL.PROD_NM as PROD_NM , //I want to sum the quantity on the basis of […]

One Table is not being created other is being created

I am working on creating table in to my database with mysql and here is my code: mysqli_query($link, “CREATE TABLE IF NOT EXISTS `review` ( `clients_id` int(15) NOT NULL AUTO_INCREMENT, `client_id` varchar(150) NOT NULL DEFAULT ”, `rating` tinyint(2) NOT NULL DEFAULT ‘0’, `proj_date` date NOT NULL DEFAULT ‘0000-00-00’, `proj_desc` text NOT NULL DEFAULT ”, `photoname` text NOT NULL, `companyname` text NOT NULL, `feedback` text NOT NULL, `status` tinyint(1) NOT NULL DEFAULT ‘0’, `emailid` varchar(100) NOT […]

SQL query: joining 3 tables with multiple values

I’m stuck trying to combine multiple tables into a json object I can use. Hopefully, I can explain what I’m trying to do. I have 3 tables: transactions table id, client, address, city, state, zip agents table id, first_name, last_name agent_transaction id, agent_id, transaction_id Here’s how they’re all tied together: transactions.id = agent_transaction.transaction_id agent_transaction.agent_id = agents.id A single transaction can have multiple agents (inserted into agent_transaction). I’m looking to get the following out of a […]

python store results of program on mySql server

This is my code which is calling gOOgle NLP API for text processing and returning entities ,type, and salience feature of the text given in quotes.. import googleapiclient.discovery def print_sentiment(): service = googleapiclient.discovery.build(‘language’, ‘v1’) review_file_contents = “”” The Goods and Services Tax is undoubtedly the most important reform in the Indian economy this year. Launched on July 1, 2017, GST has sub more than 17 taxes under one bracket to simplify the indirect taxation system […]

Next Page »