Mysql – SELECT from table based on multiple rows
In mysql, I have a table full of attributes, looking like so: USER_ID ATTR_NAME ATTR_VALUE 1 Name Jess 1 Age 23 1 Sex m 2 Name Jess 2 Age 23 3 Name Ann 3 Sex f (Note that not every…
In mysql, I have a table full of attributes, looking like so: USER_ID ATTR_NAME ATTR_VALUE 1 Name Jess 1 Age 23 1 Sex m 2 Name Jess 2 Age 23 3 Name Ann 3 Sex f (Note that not every…
I have a table as in sample below | C1 | C2 | C3 | C4 | r1 | a | b | c | 1 | r2 | a | b | c | 2 | r3 | c…
I'm trying to think what the most efficient way to do this is, hopefully you can help. I have two tables, one is for Customer Call data (customer calls in to a customer service number), the other is invoice data.…
I have 2 dedicated servers, S1, 24 cores and 128gb RAM, and S2, 8 cores and 64GB RAM. Both server CPUs have multithreading. On S1 I run cPanel and S2 serves only as a DB server( remote ). Both servers…
I have heard I should avoid cross join so my question is how you would rewrite this query without cross join ? SELECT p.*, po.*, pt.* FROM product p CROSS JOIN LATERAL ( SELECT json_agg(name) AS product_options FROM product_options po…
I select some tables with json_agg and json_build, all works but I got some data that I dont want it, My product_media (pm) is empty there are no images, if I use json_agg(json_build_object)) then I got 3x times all rows…
New to MYSQL. I'm trying to create a query that essentially selects employees who have mentored more than 2 people. The mentored_by column uses the SSN of employee's to tell who has mentored who, So you can see that that…
I'm trying to figure out a way to list all numbers between two columns (INT) and join them in a third column where all numbers are seperated. Eg. Column A Column B Column C 100 105 100;101;102;103;104;105 10 14 10;11;12;13;14…
I have this user_id which works as a FK for both tables of station and types . Data definition: create table public.types ( id uuid not null default uuid_generate_v4 (), name text not null, price numeric(10, 2) not null, user_id…
Here is my array for JSON I am trying to creating a JSON array with this code and then inserting the data in my sql but it is not working with inverted comma like "The text is with inverted comma's"…