Skip to content

Tag: sql

MySQL merge two tables with the same IDs

In table_A I have data from this week, the IDs started from 1 up to 5000. In table_B I have data from last month, whereas the first let’s say 3000 IDs conflict with the ones in table_A, and it’s not the same data for all of the IDs (ID 1 in table_A is not the same as ID 1 in

SQL SELECT “pair” records

There are cities, suppliers, and customers tables. Each supplier, (as well as customer), is located in one and only one city. How could I select pairs of supplier and customer within the city, where each of them is mentioned only once? P.S. if there is no “pair” NULL should be instead. E.g.: cityI…

is it possible to do a conditional concat?

I have a query that pulls different data but for one field it concats its since the URL is partially filled in my db but the problem is if logourl is blank then I just get https://my_url.com instead of the full URL. This is having down stream impact. Is there a way to only concat if logurl is not null?

Write columns as rows (PostgreSQL)

I have a table: campaign_id media installs content_view date unique_purchase 7564 google 613 45 2021-09-01 1 7564 facebook 21 33 2021-09-02 2 3451 google 83 12 2021-09-01 0 I want to create view: write installs column values as metric_key=installs, metric_name=installs, metric_value=… write content_view…

Insert price to the pivot table

I am trying to insert data to a pivot table order_serrvice using arrays I follow this code: https://blog.quickadminpanel.com/master-detail-form-in-laravel-jquery-create-order-with-products/ the column qty and service was inserted properly but the price does not, I dont know why? order_service table: OrderCont…