MYSQL - Whitespace issue Group by

I am performing UNION while getting the same type of information (company_name, vat, and email) from two different tables (adv and pub). The SQL query is below: SELECT TRIM(UPPER(company_name)), vat, company_owner_email FROM ( (SELECT company_name, v

Generic TypeScript interface with mixed member types

For several HTML forms, I want to configure inputs and deal with their values. My types have the following structure (you may copy it to TypeScript Playground to see it in action): interface InputConfig { readonly i

Eliminate duplicates before the union

I need to run a query, that select two columns from a big table (3m+ rows, with selecting two columns, the result set is around 6-7m) and returns a list. So I used union to merge the columns into a list and also to eliminate duplicates. The problem i

MySQL optimizes a union query by using a join query

I have 3 tables - one for users, one for their incoming payments, and one for their outgoing payments. I want to display all incoming and outgoing payments in a single result set. I can do this with multiple selects and a union but it seems cumbersom

Mysql error with UNION request

select t1.tema, count(p.id_pregunta) as num_preguntas from preguntas p right join subtema s on p.id_subtema = s.id_subtema join tema t on t.id_tema = s.id_tema union select t1.tema, count(r1.id_respuesta) as preg_respuesta from respuestas r1 right jo

SQL: Paste two independent tables

I have two independent tables: Emp: id, name, bossid Data: d_id, d1, d2, d3, d4, d5 I would like to create a new table in postgreSQL: Goal: id, name, bossid, d_id, d1, d2, d3, d4, d5 What query would be suitable? EDIT Result table id | name | bossid

SQL Combines two tables in a select statement

I have a situation where I want to combine two tables for queries in a select statement, and I haven't found a working solution yet. The Situation: Table A Table B Both A and B have identical fields but distinct populations. I have other queries that

Join between two sql statements

can i join between two sql satatmnet example select ID, NAME from tab1; 12|blabla and Select DESC from tab2; vvvvvv I want to display to 12|blabla|vvvvvv I was try the the UNION select ID, NAME from tab1; UNION Select DESC from tab2; but the result w

Request without an operator Union SQL

TABLE X col1,col2 1 , 2 1 , 7 1 , 4 1 , 8 2 , 3 2 , 1 2 , 2 3 , 1 3 , 8 3 , 9 3 , 4 4 , 5 4 , 3 4 , 2 4 , 8 4 , 4 I want to retrieve the col1 values that contains in the col2 the values 2 and 4 in this case it will retrieve the values 1 and 4 How can

c # Merge lists with double properties

I have searched for this code online to merge several lists and return one. The code works if all properties are string but I get an error if some of the properties are double. This error is "Operator '??' cannot be applied to operands of type 'doubl

Union of Two Int Arrays in Java

This is my code import java.util.Arrays; class union { public static void main(String args[]) { int[] A = new int[1000]; int[] B = new int[1000]; int[] C = new int[2000]; for (int i= 3;i < 1000 ; i += 3) { A[i/3] = i; } for (int j=5; j < 1000; j +=

Mysqli: loop requests

I need to perform 'n' unions using mysqli (where n changes based on user input). For instance: select a from b where a=c[1] UNION select a from b where a=c[2] ... UNION select a from b where a=c[n] Is there anyway to do this iteratively? Something li

Optimization of a MySQL query with UNIONS

I've got a query (which works) to show the average number of replies to messages containing specific keywords. But I think it could be optimised - we're worried that as the database grows this query will become very slow, especially if we use a large

Should I use an SQL union or join?

I'm trying to get the zip codes and the # of calls for that zip code for 2 tables I have, patients and physicians. I'm getting the #of calls by counting the zip code, like if there are 5 patients with zip code 79555 then the count would be 5. If pati

MySQL Creating an advanced query

Summary So I have 3 tables, which I have screenshots below. Every user will get 10 slides by default when they sign up, so that information is in the "slides" table. The template_id is just another table I have which is identical to the custom_s

Union with NHibernate and criteria?

Union with NHibernate and Criteria: Is it possible in Criteria or QueryOver? If not, is there any other way to achieve a union of two result within the same query?You can't do a union directly, but you can do two future queries and union the results

SQL query UNION with additional field in the results

I have a SQL query that is working well except I would like to bring the results of another column in the first db with it. This is what I currently have: SELECT parts1.PART_NBR, parts1.NIIN FROM parts1 WHERE parts1.PART_NBR='$pn' UNION SELECT parts2

Mysql Activity Union Request

right to business. I have an activity feed which gets all different kinds of activity from different parts of my site sorts them all out by means of using UNION and an ORDER BY and then a LIMIT to get the top 25 and then displays the activity. My fel

MySQL Union Query w / Join Left - Sort by Error?

We have a Union Query. Here's a basic (similar) example: SELECT a.Name, b.Info FROM a LEFT JOIN b ON (a.ID = b.ID) WHERE a.Name LIKE "a%" UNION SELECT a.Name, b.Info FROM a LEFT JOIN b ON (a.ID = b.ID) WHERE a.Name LIKE "b%" ORDER BY a