Skip to content

Tag: sql

PostgreSQL missing FROM-CLAUSE entry

I have the following query: It tells me: ERROR: missing FROM-clause entry for table “sb.bookings” LINE 2: SELECT “shiftId”, “sb.bookings”.”state”, “visibleAt” FRO… I wrote it as “sb.bookings”.”state” because state is in …

Unknown column in field list when use join MySQL

I have 2 tables like this: product_master: campaign_product: This tables link with foreign key product_id I want to get all product data with campaign_code column. I don’t want to get 2 campaign_product row with same product_id. So I use this query: It got error when I run: Error in query (1054): Unknow…

Reverse order of every other character in a string

I’m currently working on a project where the data I’m receiving is being given to me in a messed up order. I need every 2 characters to switch places in a string. Currently I have the below code, but it is ungodly slow in a function or stored procedure. Any help would be appreciated. Ex: FK741 OCE…

Equivalent of string contains in google bigquery

I have a table like as shown below I would like to create two new binary columns indicating whether the subject had steroids and aspirin. I am looking to implement this in Postgresql and google bigquery I tried the below but it doesn’t work I expect my output to be like as shown below Answer Below is fo…