Skip to content
Advertisement

Tag: database

Two foreign keys, only one can be not null at a time

I have a database table with two foreign keys pointing to two different tables. The business logic requires an “either or” relationship; only one foreign key can be NOT NULL at any given time. Here are the four possible states the foreign keys can hold based on the business logic: NULL, NULL – okay number, NULL – okay NULL, number

Joining one table twice and counting records

I have 2 tables. One is master and thee other is a lookup. TblMstr and Cmaster Tblmstr Cmaster I need to get how many Registered Nurse for each question have Strongly Agree, Disagree and Agree. Similarly for Nurse Practitioners and Pharmacists. Answer Hmmm . . . You can join twice. Once to get the occupation and once to get the

UNION ALL not combining rows

I have this table called “valores_indices” where it imports stocks values every 1 hour, I need to get the values from each monitored stock at 8am and 6pm, those being respectively my “vlrAberto” and “vlrFechado” selects I don’t get why these are not merging, I’ve done it before, any help would be appreciated since I’m running out of ideas, I’ve

Find rows using in between values in MySQL

I found it really hard to come up with a descriptive problem title, so I’ll give a bit of context. We have a list of boats and a list of docks. Boats can be transferred from one dock to the other on a specific datetime, or it could be at no dock at all. I’m trying to find out which

Advertisement