Why do all three of these return a value of 1 in redshift? select strpos(‘X’, ”) select position(” in ‘X’) select charindex(”, ‘X’) Answer Because the empty string is the very first part of all strings.
Tag: sql
Converting image files to VARBINARY(max) in flutter
I need to store images that are captured using “image picker” in a SQL server database now, I know that the images should be stored in a “VARBINARY” datatype. I tried to convert the XFile “image” that I got from the “ImagePicker()” to VARBINARY and these are the…
Executing a StoredProcedure in Dotnetcore3.1
I created a Stored Procedure by Selecting values from 2 different tables. Now the problem I have is to execute and read the result data from my dotnetcore 3.1 code. I am not sure if the code I have written is correct. I am using IQueryable<AppUser> but, The SP contains a mix of AppUser and CourseMarks. …
constructing a message format from the fetchall result in python
*New to Programming Question: I need to use the below “Data” (two rows as arrays) queried from sql and use it to create the message structure below. data from sql using fetchall() ##expected message structure I tried to create below method to iterate over the rows and then input the values, this i…
Difference of values in the same column ms access sql (mdb)
I have a table which contains two column with values that are not unique, those values are generated automatically and I have no way to do anything about it, cannot edit the table, db nor make custom functions. With that in mind I’ve solved this problem in sql server, but it contains some functions that…
Join on Id in Variant (Array) Snowflake
I have two tables t1 and t2 created as follows: Create Tables Goal I am looking to join t2 to t1 if the id of the record exists in the t1 variant array. What I’ve Tried I came across the ARRAY_CONTAINS function which looked perfect. But with the following I am receiving no results: How Do I Get This? An…
MySQL PHP insert new row where rowNum column values always remain chronological by date and time
I am trying to create a SQL query (or multiple queries and logic in PHP) to insert new rows into MySQL db table (say table name is student) where the rowNum column values always remain chronological dependent on a separate date/time column. This means that if the row I’m inserting has the greatest/max/l…
Syntax issue with UPDATE query using WHERE and LIKE
I am trying to update an empty field in my table to show “Spray Guns Service Kit” if the product code field has “ASPASK” in it. This is what I have tried thus far: Access keeps telling me I am updating 0 rows when I should be updating 100s. However, when I change the code to it works b…
SQL count when equation of two columns are true
I have a sheet with rows (id and year). See below: id year 101 2002 101 2006 101 2010 101 2014 101 2018 102 2002 102 2006 102 2010 102 2014 103 2010 I simply want to regroup and reformat my table to look like this: id 2002 2006 2010 2014 2018 101 1 1 1 1 1 102 1
Select if date is older than 30 days. What to do if format is wrong?
I want to select all entries where the column “date” is older than 30 days. The problem is, that I dont have the date saved in a supported format. My date is saved as ‘DD.MM.YYYY hh:mm:ss’. Is there a way to get such a selection within sqlite without changing the give database? Or is m…