Most voted "join" questions
Use this tag when the question refers to the syntax/behavior doubt of the JOIN command. A JOIN is a general operation in relational algebra for a combination operation on two or more relations in a relational database system; it is also the keyword of the SQL language to perform this operation.
Learn more…290 questions
Sort by count of
-
1
votes1
answer962
viewsQuery SQL returning duplicate records
I have two tables (adwords_performance and analytics_transaction) and I need to make a SELECT adding up the columns adwords_performance.clicks, adwords_performance.impressions and…
-
1
votes0
answers41
viewsFormat JOIN result object
[PROFESSORES] id | nome | 1 | Gilson | [CURSOS] id | nome | professor_id 1 | Photoshop | 1 2 | AutoCad | 1 I would like that in the result of my SELECT, the object comes in the format: (Not…
-
1
votes1
answer41
viewshow to make a Join Inner picking up the description
my tables: agencias (id, nome_agencia, ads -> FK pra tabela de baixo) ads (id, nome, agencia -> essa é FK pra tabela anterior) the problem is this: each agency will have an ads in the ads has…
-
1
votes1
answer80
viewsSelect from three tables in a list - MYSQL
I have three tables: ESCRITORIOS id nome ESCRITORIOS_SEGMENTO id_escritorio id_segmento SEGMENTOS id nome_segmento What I need is to give a SELECT to list this information like this BLAH SEGMENT:…
-
1
votes1
answer2951
viewsJOIN 3 different tables display list
Good Morning Everyone. I’m trying to join 3 tables and display in a list, but I’m not getting along. I drew (WITH LESS LINES) the tables in the database and an idea of how I’m trying to list the…
-
1
votes3
answers300
viewsRelationship of tables
Good Night, I have a database with several tables and need to make a query relationship 4 tables CREATE TABLE IF NOT EXISTS `cad_cliente` ( `id_cliente` smallint(5) unsigned NOT NULL, `nome_cliente`…
-
1
votes1
answer39
viewsSQL server 2012, ex fix
check if the answer of the exercise below is correct: List the names of customers (Cli_Nome) that have NO NULL BONUS and bought products with code (pro_codigo) greater than 5 and less than 10.…
-
1
votes0
answers162
viewsINNER JOIN returning error
I’m trying an INNER JOIN between 3 more tables returns error, I don’t know what’s wrong. Query: SELECT aa.arq_arqid, aa.arq_nome, aa.arq_nomecrip, aa.arq_datetime, u_usuarios_u_userid…
-
1
votes1
answer633
viewsHow to JOIN where the identifier could not be associated
I have the following query ready on an old system: SELECT regional, r.cod_gerente AS cod_gerente, u2.username AS nome_gerente, s.COD_REPRESENTANTE AS cod_representante, u1.username AS…
-
1
votes2
answers71
viewsProblems in an SQL query
Hello, in the following query, an error is shown in the: select fto.id_taxon, fto.cd_sexo as fto_cd_sexo, fto.cd_idade as fto_idade, x.ftv_cd_sexo, x.ftv_cd_idade, x.id_fv from tb_foto_ocorrencia…
-
1
votes2
answers65
viewsGet records from 3 tables with JOIN
I need to get data from 3 tables in the same SELECT. I just need to get user data from the table users, take the quantity of quotas (column quantity_quotas) that the user has of the table quotas (if…
-
1
votes1
answer451
viewsSort result of a JOIN query based on the number of records in one of the tables
Assuming I have two tables in my database (pedidos and pedidos_itens) how I can obtain data from requests ordered by orders containing more items? I’ve tried to make a Right Join, but I don’t know…
-
1
votes1
answer164
viewsList posts of friends
I have a database with the following structure: Table users: usuario_id Primária int(11) nome varchar(128) nascimento date Table friendships: id_amizade Primária int(11) id_remenente int(11)…
-
1
votes2
answers908
viewsINNER JOIN in the same table
SELECT Agendamento.E3TimeStamp AS Data,Agendamento.Lote, Produtos_values.name as NomeProduto, Produtos_ValueData.TemplateID AS mp_produto FROM produtos_values inner join produtos_valuedata on…
-
1
votes1
answer153
viewscreateQuery(HQL) returns Nullpointerexception when trying to perform LEFT OUTER JOIN
Personal talk, I have a problem trying to run an HQL on my application. The HQL is basically this: select c.id, c.solicitante from <mypackage>.Exame c LEFT OUTER JOIN…
-
1
votes2
answers444
viewsJoin returning many records
Hi, I’ve researched here about this error and I haven’t seen one that fits my problem, so my problem is that I have two tables, I need to get some information from table B and insert in the query…
-
1
votes1
answer691
viewsHow to verify, amid a select, the existence of relationship of a record of an A table with records of other tables
I already know I’m a beginner and maybe I’m asking something simple, but come on. I have two tables, PROMOTIONAL and PRODUCTS, and a PRODUCT can relate to zero or many PROMOTIONAL records. What I…
-
1
votes1
answer1113
viewsDifference between INNER JOIN, JOIN and WHERE?
I need to perform a query that return me information according to a certain condition, I have always used the Where for not knowing if he could use another method. So what’s the difference between…
-
1
votes1
answer3026
viewsLeft Join returning only 1 record for each relationship
I need to join between 2 tables where I need only the last record of the 2nd table (only 1 record of table 2 for each record of table 1). SELECT a.Campo1, a.Campo2, a.Campo3, a.Campo4, b.Campo1,…
-
1
votes1
answer62
viewsLeft Join repeat tables
I’m trying to assemble a select that has the result below: With select below I can show the null in just one column. How could I make it work for 20? I have from item_1 to item_20 and the…
-
1
votes2
answers60
viewsmysql_num_row with Inner Join
I have 2 tables: Leads Shops The relationship is as follows: 1 store -> N leads I need to list the number of registered leads for each store and then sort in descending order to know which store…
-
1
votes4
answers1903
viewsHow to join two lines in SELECT?
I’m having a problem joining 2 lines. I did a lot of research, but I couldn’t find anything that could solve my case. In the query below, there are two SELECT, which return two lines for each…
-
1
votes2
answers332
viewsMysql - Select between 2 tables with "String" field
I would like to know how to do a Select to return the nonexistent records, comparing two tables with String field. Example: Tabelas Campo1 Campo2 Tab1 Nome Tel Tab2 Nome email The result of the…
-
1
votes1
answer40
viewsHow to catch the latest releases of an Inner Join
Staff to making a query in 3 tables with Internet, follow the code: select itensVenda.idVenda, itensVenda.idProd, itensVenda.qtd, produtos.id, produtos.descricao, produtos.foto, venda.id,…
-
1
votes1
answer326
viewsHelp with Inner Join: "No space left on device"
I don’t have much knowledge in programming and experience in SQL, however, I need to do a search in a Postrgeesql database (I’m using pgAdminIIII) where I need to join two tables. create table…
-
1
votes2
answers68
viewsCreate more fields and avoid JOIN decreases load?
I have 3 tables that are connected: 1ª tabela: GRADE (grade de horários) Campos: ID - GRADE - ESTADO - VALIDADE 2ª tabela: BLOCOS (blocos de horários da grade) Campos: ID - ID_GRADE - BLOCO -…
-
1
votes2
answers801
viewsupdate sql relating a column with external value
Good morning, I’m having a hard time updating SQL Server. I have the following situation: Table 1 ID Codigo Table 2 ID Nome And I have an excel file like this: Excel Codigo Nome I need to update the…
-
1
votes3
answers1607
viewsHow can I view data using JOIN?
I am making a section on my site called "My Ideal Board", in it the user inserts his data (weight, height, etc), a comparison is made in the bank (join) and is returned to the user the ideal board…
-
1
votes0
answers96
viewsJpaupdateclause with Join
I have the following entities: @Entity @Getter @Setter @NoArgsConstructor @Table(schema = "MYDB", name = "TB_TESTE") public class Teste implements Serializable { @ManyToOne @JoinColumn(name =…
-
1
votes0
answers60
viewsRelate more than one column to lambda Expression
I have the query below that relates only the Processoid. I need to know how to relate processes and processes lists by Processoid and Grupoid. I have consulted in several groups and did not get an…
-
1
votes1
answer266
viewsUsing Inner Join correctly and aggregating results
In my comic book, I have 4 tables: Aluno, Ano, Matérias and Nota. They are mounted as follows: Tabela :: Colunas ---------------------------------------------------------- Aluno :: AlunoID |…
-
1
votes1
answer37
viewsDuplicity with JOIN
Hi, I need a hand, if you can help me, I appreciate. I need to query between three tables, however, when I search the query is returning me duplicate lines: SELECT US.NOME AS PROFISSIONAL,…
-
1
votes1
answer675
viewsWhat is the difference between JOIN and UNION in SQL?
What’s the difference between JOIN and UNION in SQL? I thought a query made with either of the two would result in the same table, but I’m taking a course at Datacamp where the teacher says these…
-
1
votes0
answers26
viewsR and SQL - How to join a data.frame in R with a table in SQL?
I have a table in Postgresql that contains the column "cnae". I also have a data.frame in the R with columns "cnae" and "Description". I need to move the "Description" column up to the table in…
-
1
votes2
answers1807
viewsINNER JOIN with equal fields in a table - Error: #1066 - Not Unique table/alias: 'tb_usuario'
I have 3 tables as follows: At tb_usuario, I have two types of users (buyer, seller) in an ENUM field to differentiate the type of user. In the shopping cart I have the user Ids, product and…
-
1
votes3
answers922
viewsHow to create a table (empty) from a selection of other tables?
EXAMPLE: I have two tables : Tabela1 : two-column id_product, product name; table 2 : three-column id_brand, id_product, tag I would like to create a Tabela3 from a selection of the Tabela1 and…
-
1
votes1
answer424
viewsUPDATE with 2 Joins POSTGRESQL
I would like to ask for help with an update on Posrgresql I need to update the value of a column in a table, but that goes through conditions of 2 tables. I tried the code: update proced_conv set…
-
1
votes2
answers576
viewsProblem when performing Join in tables with generalization
I’m having difficulty performing a JOIN in tables the problem is the following: In a school bulletin system I have users, including students, guardians and school employees. I need to generate an…
-
1
votes1
answer182
viewsQuery Linq C#
Good afternoon I have the following database structure: Tables: -User -Group -Permission And all relations N to N: Grupousuario Permissaousuario Permissaogrupo I set up a query to return the user,…
-
1
votes1
answer507
viewsString binding of SQL tables instead of id
Data from user accounts id nome sobrenome pais estado cidade telefone url_perfil Login data of users id email senha prioridade My doubts are: How can I link them to foreign key using string ? It is…
-
1
votes1
answer561
viewsMysql SELECT with JOIN and LIMIT in child table
I have a table catalogo related to another table imagens. Each record in catalogo has N images. I need that in a SELECT with INNER JOIN imagens, only 3 images are returned for each table row…
-
1
votes1
answer134
viewsHow to return driver names in SQL table?
I have the following tables below, and I would like to return only the name of the pilots who never participated in a race in a Brazilian circuit in the country brasil. Table structure: PAIS (id,…
-
1
votes2
answers150
viewsQuery with JOIN in 3 tables
I have the following tables: livroautor id idautor idlivro ------ ------- --------- 1 1 (NULL) 2 2 2 3 3 3 4 4 4 5 5 5 6 6 (NULL) 7 7 5 8 8 2 9 9 2 10 10 (NULL) book id titulo resumo isbn paginas…
-
1
votes2
answers855
viewsUpdate Inner Join (update in two tables) - Php; Mysql
I have two tables and I want to do a Join to update both at the same time. Table1: Clipping (id, dia_semana, data) Table2: imagemClipping( id, id_clipping, titulo, dia_semana, data, imagem)…
-
1
votes1
answer49
viewsJoin in the database
I am developing a software where the user selects the items from his home, selects how long not to clean them, and at the end fills a form to receive a discount by email and clean the items. All…
-
1
votes0
answers43
viewsdatatables does not display data with a query using JOIN. What to do?
<?php include('../conection/db.php'); include('function.php'); $query = ''; $output = array(); $query .= "SELECT i.Tipo as Tipo, c.Descricao as Descricao, c.Anexo as Anexo from tbl_instituicao as…
-
1
votes1
answer949
viewsData being repeated when using INNER JOIN on Oracle
I have three tables, which are the following : ALUNO,CLASSE and MATRICULA. PUPIL NR_RGM NM_NOME NM_PAI NM_MAE DT_NASCIMENTO ID_SEXO CLASS CD_CLASSE NR_ANOLETIVO CD_ESCOLA CD_GRAU NR_SERIE TURMA…
-
1
votes1
answer813
viewsINNER JOIN WITH WHERE MYSQL
I have a foreach that runs each product, then I would like to make a query in two tables from that ID, only I’m not getting, what I’m doing wrong? $collection =…
-
1
votes1
answer37
viewsUpdate the remainder of a table from the data contained in a row
The figure below explains well what I want to try to do (and what I tried to do but it didn’t work): That is, I need to update some rows of a table with the same data contained in a row…
-
1
votes2
answers85
viewsInner Join - SQL Server
Guys, I need someone’s help to understand the mistake you’re making. I have two tables as the code shows, and in one of the tables the column "Code" is with information. I need to enter the codes…