Category "sql"

Effective query than AND operator in SQL

I am using Oracle database. The below query is not working as expected. select * from cst_cust_attributes where attribute_value='event' and attribute_value='

Why does a known type produce a runtime error but an inferred type produces a null value?

Let's take the following example from BigQuery, but it's the same across all other databases I've seen: with tbl as ( select [1,2,3] as arr, '{"IDS": [1

WP Slow queries / Duplicated queries - images

I have problems with slow and duplicated queries, I'll need assistance, I'm working on this for more than 10h+. Latest WP version - Latest Flatsome theme and ju

Trying to get only cells with certain initials but giving me syntax error? SQL

So my assignment question is to "Get a list of all books withdrawn by people with the initials 'B.W.'. Show a column for the first name, last name, initials, an

SQL Query for persons liking both fruits and vegetables [closed]

I have a situation I am trying to resolve. Might be simple but I can't figure it out. I have simplified my table that I am trying to pull data

WHERE clause with multiples conditions with values from the SELECT

I need to edit an old Access form. When a person enters information into a form field, a number associated to a name is found through a SQL SELECT statement. "S

is there a way to extract duplicated row value in sql as the key/grouping value?

I have following two tables users id | name 1 | john 2 | ada events id | content | userId 1 | 'applied' | 1 2 | 'interviewed| 1 What would be the

Simple spring data jpa transaction to small table on mysql database is hanging indefinitely

I have a spring data jpa query that reads a row from a mysql table with a pessimistic lock. In my environment, this table only contains one row so it should be

deleting all entries with FK when PK entry is deleted sequelize

I have a post and a notification model. notification has a onPostId FK. When a post is deleted how can I let sequelize know to delete all the notifications that

Multiple values inside SQL LIKE

This is working: SELECT * FROM table WHERE name LIKE '%ab_cd%' How to include '%ef_gh%' in a single/multiple statement? My try: SELECT * FROM table WHERE name

Accidentially deleted rows from pg_enum

Was looking to drop an enum and did it incorrectly by deleting the rows from the pg_enum table. I should have removed it with this: DROP TYPE IF EXISTS "enum_Or

Order of CAST() and COALESCE() matters in MariaDB

I have a strange problem: There is a price in a JSON column in a table and the following statements give different results while they should give the same thing

Can not safely replay call when trying to assign and use a variable in procedure

I am trying use the data from a column in one table as column aliases of another table. DECLARE var1 VARCHAR(20), var2 VARCHAR(20); BEGIN WITH TABLE1

How to map an entity with multiple levels of clearance/perks?

For example, say I have a clearance pass entity, with basic, intermediate and high level clearance. basic has clearances of x, intermediate has clearances of x

SQL - How to join tables with dates to get overall view of ALL dates

Using a bespoke ERP system with T & A built in. Table 1 has dates with holidays types i.e. bank holidays, user booked holidays - and a user id. Table 2 has

Inserting values from another table into a column where values are null

I have a table A with ID's only and another table B with two columns, ID and Product Number. The ID column in table B has nulls and Product Number has Product N

Return ids after upsert Slick

I have a query that upserts the data to the database via Slick. I'd like to return the ids of the entities that were inserted. How can I do this using Slick in

Empty output using trino dbapi in python

I am getting empty output in the below code but when I remove the part of and I get the desired output. Can anyone clarify if there is any error in syntax of be

Hive subquery with Lateral View

I am trying to run the below code. I'm trying filtering on the jira_label field. I'm getting the below error. I know this means I should add aliases and I have

Real-time pipeline for processing data, insert into PSQL

I have files that will be coming in daily that I would like to process as they come in and insert into existing sql tables (using postgres). What is the best wa