Category "sql"

How to get records that has relationship with all records in another table in many to many relationships in MySQL?

I am using Laravel 8 and MySQL8. I have these tables: products id - integer name - string factories id - integer name - string factory_product

Codility PostgreSQL Question: Aggregation and conditionality in SQL query. Completely Stuck

I have been applying for Junior DEV roles and encountered a problem on a Codility take home test that I aced... except for this question. Which I bombed. I have

MariaDB. Create a trigger that deletes rows from a table older than 15 days

I want to create a database trigger that deletes automatically rows where the value of happened_at field is older than 15 days. My table rows id int(11) site_id

Join tables on dates, with dirty date field

In AWS Athena, I am trying to join two tables in the db using the date, but one of the tables (table2) is not clean, and contains values that are not dates, as

How we can use mutimap_agg function in spark sql and also suggest if any equivalent or alternative function to this

Can anyone help how multimap_agg function in SQL and can be used in spark sql

Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login failed for user 'sa'

I am trying to execute one stored procedure using 'sa' user through perl script save this line in a perl file and execute that perl file system("start /wait s

SQL Server trigger for verifying date column doesn't work

I have a table for scheduled surgeries and I am trying to write a trigger that will print a message in case the user inserts a past date in the date column (in

Duplicate and Split Row based on value by using SQL Query?

I have set of data and wants to split multiple rows based on the column value. For Example, Source Data: Expected Output: Thanks, Lawrance A

Recycler chat Pagination add new message at top

I am working on a chat app where I need to show reverse pagination and show the user's previous chat when the user scrolls up. I am first loading data from SQL

PowerApps Data Source Changed to Stored Procedure

The data source in PowerApps gallery was a SQL View. Search('[dbo].[vwCandidate]', textSearchCandidate.Text, "NameLast", "NameFirst", "MiscellaneousTags", "Ema

Laravel print last executed SQL query with Query log

DB::enableQueryLog(); $mines = Cranks::where([['crank_id', '=', $this->crank_id], ['mine_id', 'like', '%'.$script_value->mine_id.'%'] ])->get(); $query

PowerApps Data Source Changed to Stored Procedure

The data source in PowerApps gallery was a SQL View. Search('[dbo].[vwCandidate]', textSearchCandidate.Text, "NameLast", "NameFirst", "MiscellaneousTags", "Ema

SQL iterative loop to see if employee works on all projects

The query I am supposed to form has to accomplish the following task: Retrieve the names of all employees who work on every project. I currently have three t

SQL Stored Procedure Parameter set to Uppercase

I want to force a user's string input in a stored procedure to uppercase. I tried writing UPPER prior to the @parameterName but I got a syntax error. Is this

SQL Stored Procedure Parameter set to Uppercase

I want to force a user's string input in a stored procedure to uppercase. I tried writing UPPER prior to the @parameterName but I got a syntax error. Is this

Query to update the column of second table based on newly generated id of first table

I have two tables company_types and companies_profiles. company_types_id of company_types and company_type_id of companies_profiles has one to many relationship

Troubleshooting Errors with Two SUMs

I have a table, it's going to be used for a supplier scorecard, with eleven different fields that can be assigned a value of 1-5. Null values are allowed. I

SQL WHERE/AND error when using it multiple times

I've started learning SQL on Friday. I'm using pgAdmin4 I'm having trouble with one line on this code: SELECT first_name, last_name, nationality, date_of_birth

Mysql compare if date is at least two day away from now

I have a table, has field named date with type date. I have a row with date=2021-08-11, I want to perform an update, if table.date is more than 2 days from curr

Conversion failed when converting the varchar value 'Lagtime' to data type int

I am trying to use the code below to count the difference in days between the encounter begin date and submission date. SELECT e.EncounterId, e.Encounter