I have the following structure with an enum { ‘ready’, ‘set’, ‘go’} on name: How can I put a constraint on it so that there will only ever be 3 true’s (one on ready, one on set, and one on go)? Answer You can use filtered unique indexes (or as Postgres calls them R…
MySQL query to find values in table with given value and find others that are similar
I have a table called followers and I want to be able to find the current users followers, display that list, and then compare those values against another user ID to see if they are following them or not from that same table This is the table I’m using currently to get the list of followers for a speci…
T-SQL sub select to retrieve rows with columns that have values instead of NULLs
This example is as close as I can demonstrate for the problem I’m trying to solve. For this case the sub-select has some mostly duplicated rows with the only difference being that some have a delvieryDate and some do NOT. If a row of data is available with the date, I want that. If not I’ll need t…
Dynamic pivot unknown number of rows – Sql View
I’m using SQL to create a database VIEW from the table below. ItemCode |BcdName |BcdCode | ————————|——————|————-| 03616006.ERA …
How to remove data from an SQL row but not delete it PHP
I am working on a login system that will log a users IP for a day after they login and clear it after one day. I know you can delete rows but i don’t know how to clear a row. The table i have is this. …
Is it possible to increment the maximum row size in AWS Athena?
I’m running this query with AWS Athena: SELECT t1.* FROM “db”.”tbl1″ t1 INNER JOIN “tbl1″.”ema” ea ON ea.id = concat(t1.numc,t1.nummt) WHERE ea.cod1 = ’23’ and ea.cod2 = ‘776’ And getting …
How do I add a count() for one table into a SQL query that has joins for multiple other tables using SQLite?
I have a sql statement that pulls data from multiple tables. This query gets all employees and their biographic information (employee id, first name, last name, badge image, etc.): SELECT e.ID as id, …
SQL Query to return filters applicable to products contained in category AND filters that apply from remaining products once 1+ filters active
I’m displaying a list of product filters. Product filters are only displayed if they are applicable to the products contained within a chosen category. I want to expand that further so once a filter …
SQL Server Select Query With Join/Sub Query On Same Table To Create A Master Field Value
This is a weird query, and I’m not sure if what I want to do is even possible (Efficiently anyway) as it’s a bit of a weird situation. Let’s say I have the following data called ProductTable. They …
SQL groups inside groups
I have transaction data like this example: Name | Price George | 20 George | 20 George | 20 George | 30 Paul | 20 Paul | 20 Paul | 30 Paul | 30 Paul | 35 I need to group by …