I have three tables with foreign keys which should cascade on delete nevertheless when I run this only the mapping in Tagmap and nothing happens in Excerpt nor Tag. What am I doing wrong? Answer This is not how foreign keys work. You delete from the parent table (here, tag, or excerpt), and then children reco…
Tag: sql
Comparing each colum in a row to every row in the database sql
I am building a bot that matches users based on a score they get, this score is taken from calculations done to data in a database on the request of the user. I have only 1 table in that database and a few columns (user,age,genre,language,format,…etc). What I want to do is, once the user clicks “f…
SQL Flag Rows Occurring 2 Hours After Previous Flag
I have some messy RFID data due to over sensitive antenna’s. There is a physical process that tracks an RFID tag moving through different stations in a cycle. An item with an RFID tag can move through the cycle more than one time a day, but it is highly unlikely that it could start the cycle within a tw…
Column must appear in group by or aggregate function in nested query
I have the following table. I am trying to query the following: For each year that appears in the Fights table, find the city that held the most fights. For example, if in year 1992, Jersey held more fights than any other city did, you should print out (1992, Jersey) Here’s what I have so far but I keep…
Power BI – DAX List.Select syntax to return specific records
I unfortunately discovered today that I cannot use SQL to return a subset of records when Power BI references a SQL Server DB as a data source. I’m trying to do something similar to a SQL where clause using “IN” for example I’ve tried this (and several other variations) in DAX but get …
SQL: Remove part of string that is in another column of the table using REGEXP_REPLACE
I have a column that looks like so, but with more rows: Now, I am trying to remove the cat name from the message on each row in the table, so that I can see what the messages sent to each cat are, and which cats got the same message (i.e. this way I would be able to see that
Is there a way to calculate the average queue time of an entire column that contains data in time format
I have imported a data extracted from a cisco call center in SQLITE table. These data deals with information related to the incoming calls . Among this table , there is a column called “queue time” which indicates the time spent by the caller waiting in the queue before reaching an agent . I would…
fetch key value pairs from array objects in sql BigQuery
I need to parse the column mapping and fetch the key value pairs from the second object in array. I would like to create new columns with the fetched data. The data looks like this: The desired output: Answer Below is one of the approaches (BigQuery Standard SQL) if to apply above to sample data from your que…
Assigning result of For Xml and With clause to a variable
I’m trying to use XML for to concatenate a bunch of columns together and then assign the result set to a variable. I’m using ‘with’ clauses because my initial sub-queries contain calculated fields that later sub-queries need to generate additional fields. When I run it gives Lookup Err…
Get products with specific attribute term and specific category term in Woocommerce using SQL
I wish to find products with two different criteria. The code I used first to search one criteria is; This returns all those products (Object_ID) with the attribute “pa_1_scale” and ts.term_id = 400. I can also do this to return all products with product_cat and ts.term_id = 397, using a different…