Skip to content

Compare items in a SQL column with array

I have a SQL server table where I want to query for items on rows which have a value equal to an item in Array. Here’s my example: And my array: So, I want to return from SQL rows matching items in the array. my SQL query should return items where column1 matches an item in the array: This all

MySQL SubString Returns Integer

I’ve got a table with a varchar(128) field called identifier. It is supposed to get a 3 letter identifier followed by an indexing number: At some point in the past, there was a bug and about 5,000 records were input as: Our numbers do not go that high, so these values are padded with zeros (0). I wrote …

Replace NOT IN with LEFT JOIN in SQL statement

I wrote two queries which are working fine, but they are really really slow: SELECT director FROM movies WHERE id NOT IN (SELECT movie_id FROM stars_in_movies WHERER star_id = %s); SELECT …

SQL function return-type: TABLE vs SETOF records

What’s the difference between a function that returns TABLE vs SETOF records, all else equal. CREATE FUNCTION events_by_type_1(text) RETURNS TABLE(id bigint, name text) AS $$ SELECT id, name FROM …

How to compare records in a SQL Table

I have a table name TransactionTable. If InsuranceCode = ‘ADAP’ and IsADAP = 1, I have to filter these records and return the remaining records. I am trying to write something similar to this syntax. Total records in TransactionTable is 1832 and Total records on filtration criteria is 109. I expec…