UPDATE bookings b SET reservation_processed = ‘archived’ JOIN reservation_time_data r ON r.id = b.reservation_time WHERE premises_code = ‘LJJIDHhRN2ho1e3h’ AND reservation_date LIKE ‘%2020-09-10%’ …
Tag: sql
Find an entry in sql dependent on other entries in the table
How can I return all entries in a table that contain a string in a given column if the same string is also present in the same column with a given suffix ? So for example, given the suffix ‘bar’, and …
Create Missing Data Hive SQL
I have a table that has an activity date of when things change such as 2020-08-13 123 Upgrade 2020-08-17 123 Downgrade 2020-08-21 123 Upgrade Basically this in relation to a line there are 3 …
How to count non-zero numbers in a comma separated string in oracle sql
Want to count non-zero numbers from a comma separated string in oracle 12.10. If my column has data as 2000,300,0,0 then count it as 2. This gives me 2000 and 300 as result but what’s next to count it. select regexp_substr(‘2000,300,0,0′,'[^,]+’,1,level) from dual connect BY to_number(…
How do I find out which SQL queries utilize the tables in a certain database programmatically?
Let’s say that I have a table called queries, which holds hundreds of predefined SQL queries in JSON format. Then let’s say that I have two different databases, the original being a 200+ table DB and the new one being a 50~ table DB. This new DB is a subset of the original, so every table it has e…
SQL – Compare 2 tables and show non existent data
Ok, I have 2 tables that I need to do a comparison to. The idea is to show anyone in the database who has not purchased a specific product. Table 1 UserID Customer ProductsSold 1 John Cookies 2 …
SQL Select to display one to one, one to many from many to many relation
I’m trying to figure out SQL query that will list only one to one relation from below table. Below Table contain 10 record where 8 are many to many relation data and 2 are one to one relation. Request your help with SQL that I can use to query below table and list out 2 records that has one to
Creating table script with values in codebehind inC#
I want to build a console application with ado.net where I get a table from the database and convert it to a string output in a file. I want to do this with stringbuilder. But before I fetch the data …
how to improve mysql query speedy with indexes?
I must run this query with MySQL: select requests.id, requests.id_temp, categories.id from opadithree.requests inner join opadi.request_detail_2 on substring(requests.id_sub_temp, 3) = …
How to deselect duplicate entries in a query?
I’ve got a query like this: and this query returns the result like this: As you can see in the image there is 3 duplicate, unnecessary entries (no, i can’t delete them because of the multiple foreign keys). How can I deselect these duplicate entries from the result query? In the end I want to retu…