Skip to content

Tag: sql

Where clause with multi AND & OR conditions

I got a table agenda in which the admin can make a reservation for him self or for someone else (another user). If the admin make the reservation for him self in agenda.user_id will be stored the id of admin. In case that admin make a reservation for another person (another user) in agenda.user_id will be sto…

Extracting data from only the year

I have data in a table in SQL with dates, but how do I select only those that happen in 2021. (The dates look like 31-oct-2020) in the table. The dates are the actual date variable, not just text. Answer You should avoid storing your dates as text, but rather should use a proper date column. That being said, …

Find sum from 2 tables and write code in php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago. Improve this question This is the query image: This result should appear as follows: This is m…

MySQL Update inner Join with MAX Date

In MYSQL 8.0 I have two tables with following structure: I am trying to update a value of EnromentStatus in child table by joining in on Enrolment table using the TSQL below: Problem is Enrolment has multiple entries for the child enrolment so I need to do MAX(DateUpdated) to get just a single record to updat…

Output records with null values even if not present

I have a table as below in Oracle gen_id serial_code is_verified 1 fmcg Y 1 smcg Y 1 xmcg N 2 smcg Y 2 fmcg Y 2 2mcg Y 3 smcg Y 3 amcg Y Now I want the output for max gen_id which is 3 in this case and serial_code ‘smcg’ and ‘fmcg’ I can get the output easily

SQL Generate per day records between dates

I have a table that where each record has start and end dates. I need to return a record for each day between start and end date fields (including the start and end dates). Using MS SQL Server. Example: Current data Data required: Looking for recommendations. Thanks. Answer You can use recursive cte :

Inputting data into a table from two different tables

I have these 3 tables with data and then created a third table that looks like this I want to populate my new table with the Subjects who were involved in projects that were lead by Dawn Elgar (PID is 10001). Is there a way to do that across 3 tables? I am close with code that looks like this