Skip to content

Creating a mySQL sub query to list distinct rows from two queries

I have two queries: and The first query returns around 4000 values, the second query returns around 4100. I’m attempting to create a query that will return the rows which are distinct between the two values, I’m attempting this by using a nested or sub query but I’m struggling with syntax he…

SQL Group By Sum and Nulls

I have a query that fetch the sum of quantity of a certain date with a GROUP BY, but the query is giving me NULL results and not aggregating some values. Here is the query: Select VPC.Armazem …

SQLAlchemy substring is in string

I am trying to query a database for records that have a string field inside an input search string. Something like this: Of course that does not work since it is not a valid SQLAlchemy statement. This seems a simple problem but I really can’t find the right column operator. I tried the in_ operator: But…

Linq query order by giving me issues

I have a stored procedure that I wrote in SSMS using joins, show below select distinct z.size, z.SortID from [ProductAttributes] x join [Product] y on x.ProductID = y.ProductID join [ProductSort] …

Postgresql ON CONFLICT in sqlalchemy

I’ve read quite a few resources (ao. 1, 2) but I’m unable to get Postgresql’s ON CONFLICT IGNORE behaviour working in sqlalchemy. I’ve used this accepted answer as a basis, but it gives I’ve tried adding the postgresql dialect to the @compile clause, renaming my object, but it do…

What does VARBINARY(MAX) mean?

I’m trying to port a MSSQL database over to MariaDB and I’ve encountered a table creation using varbinary(max): What would this actually do and is there an equivalent type definition in MariaDB that I could use? Answer As others have stated in the comments, VARBINARY(max) in MSSQL refers to: Varia…