I’m trying to retrieve all messages of a conversation and display it’s status (read or unread). With a CASE I try to read the message.read property (boolean) and process it to a string. $messages = …
SQL: View Representing Missing Ranges
Given a table of rows each representing a numerical range. CREATE TABLE ranges ( start INTEGER, end INTEGER ) How could I create a view that represents the “holes” in the ranges? (Ignoring …
WordPress – Save Contact Form 7 fields to the database as separate columns
I am using Contact Form 7 and Contact Form 7 Database Addon – CFDB7 to save values from my form to the database. The database plugin seems to work fine and saves information to the database, I am able …
Getting a query result taken from the same data but with temporary var
I got a simple thing to do. Well, maybe not, but someone somewhere surely can help me out : P I got a simple data structure that contains expedition date delivery date transaction type I would …
Combine Queries using Union All Dynamically
I have three tables: I combined those tables using UNION ALL. My problem is, each year there is a new table to be added. One example is that Table D with corresponding record Order O1-20 and Year 2020. Instead of adding another set of UNION ALL, is there any other way to achieve the same result. I’m usi…
Conditional ROW_NUMBER() to skip nulls still counting them
I am trying to add a ROW_NUMBER column to a data set that follows the order of [Withdrawal then Fee; Withdrawal then Fee] based upon whether the column NETWORKCD is null. However, my row_number formula is still counting Nulls even though it’s not displaying the numbers, like so: I am using the following…
Update table using JSON in SQL
Is there a way to update a table using a JSON field in SQL. { “RelationshipType” : [ { “ID” : 1, “FromID” : 70, “ToID” : 12 }, { …
teradata, reset when, partition by, order by
I need help understanding the below code. I have never seen reset when used in Teradata. What does RESET WHEN do in Teradata? I understand the partition and order by part. I was also unsure why this …
Indexed View vs. Table
I had a long running query (relative to the data) that was hitting an indexed view. I thought an indexed view was physically stored data? I dumped everything into a table and ran the same query …
How to implement EVERY and NO operations for a joined ‘list’ table
I have two tables Person and _Person_Name which contains a column Name and a column Owner with Person.Id as foreign key. I’m looking for two search operations I’d call EVERY and NO. 1.) Every The …