Let’s say we have a table called Users for a fictional social media platform. In addition to regular users, some more experienced users are asked to be “greeters” where they are assigned other, newer users to greet and encourage. Because greeters aren’t always available, multiple greeters are assigned to each new user and each greeter is assigned multiple new users.
Tag: relational-database
Using INSERT and UPSERT in SQLite trigger to update one table from another table?
I’m attempting to create a SQL database for an Auction company I work for. The issue I’m running into is creating triggers that update other inventory tables from the main inventory. I’ve tried quite a few different things, but can’t wrap my head around how to get this to work. The latest trigger I’ve attempted is as follows: Additional info:
SQL Trigger for updating values from a query by id
I have three tables: employee with id(employee id), numOfTickets tickets with date, asset(id) and some more fields control with id(employee id), asset(id) when a new ticket is created it automatically inserts a row into tickets and control. Now I want to create a Trigger or something similar to automatically update the number of open tickets for each employee. A Query
SQL how do I sum up a has many relationship
So I have the following table, I managed to join users and membership tables just fine with a left join however I’ve been unsuccessful at summing up the individual customers’ total. Here’s my code, the one-to-one associations seem to be doing fine however the summing up of the total seems to not display, what am I doing wrong? is there
Relational database created/stored on client [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 5 months ago. Improve this question I’m in the early stages of designing an Electron application that
How to ignore 00 (two leading zeros) in Select query?
I am not sure whether it is possible or not, I have one DB table which is having fields refNumber, Some of this fields values contains two leading zeros, following is example. id. refNumber 10001 123 10002 00456 Now I am trying to write a query which can select from this table with our without leading zeros (Only two not
Convert values in related table to comma-separated list
I have two SQL Server tables: I’m trying to the following result where the related activities are in a comma-separated list: I tried: Can someone help me with this SQL query? Thank you. Answer You could use OUTER APPLY to aggregate the string if you’re using SQL Server 2017 or higher.
Joining two tables with same keys but different fields
I have two tables both all with the same fields Except for one. I want to combine these two tables with the resulting table having all the fields from both including the two fields that are not the same in each table. I.e: lets say I have table order_debit with schema and table order_credit with schema What I want is
How to copy information in SQL from one table to another
I need to build a query to copy information in a column from one table to a column in another table. This is how the tables looks like: People: PersonId Name StatusId 1 John 2 Jenny 3 Steve …
Canonical way to store reciprocal data sql
I got a lot of instances of the same Class. Now these objects can be linked and this link can have a weight. Like in an undirected graph. Now I want to store the relationship between each two objects in my mysql database. Data looks like this I could do create a table with this structure: object1_id | object2_id |