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
answer346
viewsJoin fetch multiple returning duplicate values JPA Criteria API
In the method in question I want to return the consultation with the joins of employee and company. However, the Company class is related to the Query and the Employee, and is returning duplicate in…
-
1
votes2
answers425
viewsI need to relate two tables in order to bring me a result within the conditions I want
I’m using the SQLSERVER Condition(What the result should return to me) Creation of the agenda. Necessary creation of the flow for creation of agenda and blocking to reserve the vacancies; When…
-
1
votes2
answers494
viewsSQL Left Join - shorter date longer than current date
3 tables: Processo, Evento, Alerta The goal is to make a query that returns all processes by adding the columns of the most recent event type and date MAX(DataEvento) and the next warning (shorter…
-
1
votes1
answer38
viewsData return en JSON in an array , uploading the database ID by the respective Names. How can I do this?
I made this code, but it only returns me the ids, and I would like in the place of the ids he did a search by Ner Join in the database and returns in place of the ids the names. Php code: <?php…
-
1
votes1
answer75
viewsTake value from right set with 'ambiguous' fields
I am making the following query to my database: $escalacoes = 'SELECT * FROM escalacoes AS e JOIN jogador_rodada AS jr ON e.id_jogador = jr.id_jogador WHERE e.rodada = ('.$rodada_atual.' - 0) AND…
-
1
votes1
answer81
viewsMysql - Inner Join runs on PHPADMIN but not on php SCRIPT
I have a small PHP script to interact with MAKERIOD. When I run select in PHPADMIN I get the return : "Showing 0 - 16 records (total 17, query took 8.0945 seconds.)" SELECT Tbdiario.cn1,…
-
1
votes1
answer73
viewsJoin SQL server
Good afternoon, I started working with sql to 3 mesês and I’m picking up on an application. I have 3 Tables which I have information associated with by "registration" I would like to get all the…
-
1
votes1
answer220
viewsINSERT WITH TWO TABLES - PHP
I have the table students and the table payments, I am doing a gym system. I linked the two tables by placing the id_students in the payments table as foreign key. I want when registering student…
-
1
votes1
answer90
viewsInner Join with Where and multiple tables
I am mounting a query, where I need to Join between two tables (because the data will be in the main B but not in the complementary BC) and a third table that necessarily need data, which will…
-
1
votes1
answer162
viewsINSERT WITH JOIN DUPLICATING DATA
Hello, I have these 3 tables in my database: Table colaboradores Table cursos Table c_vendas_itens I would like to make a Join of the three tables and save in another one, I can do this through the…
-
1
votes0
answers341
viewsSQL using Join with subquery
I have the following code: select FACAV_CDMATCOOP,CCCCO_NOCOOPERAD,FACLA_ORIDAVIAR FACLA_QTPESOLOTE, FACLA_QTENTREG1, FACAV_ORCDAVIAR, FACLA_NRLOTE, FACLA_DTYALOJA, FATCR_QTPESOMED from FACAV F…
-
1
votes1
answer173
viewsSequelize Associantions
I have 2 models: user Features: const DataTypes = require('sequelize'); const database = require('../config/dbconnection'); const user= require('./user'); const user_features =…
mysql node.js join mariadb sequelize-jsasked 5 years, 9 months ago Guilherme Monteiro de Oliveira 21 -
1
votes1
answer590
viewsDOUBT SELECT WITH INNER JOIN AND COUNT
Hello, I am relatively new when the subject and database and need to generate a report with the following information,: Client name Qty of purchases made by each customer Total in R$ of each…
-
1
votes1
answer54
viewsHow to use Join or Aggregate in SQL query
When performing the query in a given table, numOrc is a list that may contain one or more values. So I needed to concatenate these values into one string, using ; as a limiter. So I tried: var model…
-
1
votes1
answer85
viewsJoin C# EF6 lambda Expression
I’m having a problem, I’m doing a Join with C# with EF6, I have two unrelated tables Invest and Encarteiramento and need to make a Join in Invest where agency and account is equal to, agency and…
-
1
votes2
answers72
viewsCount values in multiple related tables
I have 4 tables tbl_Distrito, tbl_Unidade, tbl_Servidor, tbl_Processo. tbl_Distrito: Cod_Distrito, Nome_Distrito tbl_Unidade: Cod_Unidade, Nome_Unidade, Cod_Distrito tbl_Servidor: Cod_Unidade…
-
1
votes1
answer32
viewsQuery using Inner Join and left Join data together
I’m making a system with php and mysql to control the input and output of vehicles in a company, so there are two tables, one to record the output information and the other to save the return…
-
1
votes0
answers84
viewsMultiple Joins to add different values of the same column
I’m having problems in a query (Firebird) with several Selects for the same Stored Procedure (SP_PRODUTO_MOVIMENTO), with practically the same parameters, differing only in the values of a column…
-
1
votes1
answer112
viewsSELECT in two different tables with variables of the same name
I have the following consultation to be made: "SELECT DISTINCT andamento_processual.licenciamento_cod, andamento_processual.inter_simplificada_cod, andamento_processual.inter_pretendida_cod,…
-
1
votes1
answer31
viewsDoubt about SQL
Good afternoon guys, I am learning SQL and I have to do an exercise that is: Select the first and last names of employees and consultants working in the "Financial" department. Turns out I’m trying…
-
1
votes1
answer69
viewsHow to treat a field in SQL SERVER
I have two tables in SQL one of EMPLOYEE and another of Dependents and I need to bring the name of all employees, regardless of whether or not they have dependents and for those who have, I need to…
-
1
votes0
answers43
viewsSelect data in three Mysql tables and bring the latest result with the sum
I am trying to join data from three tables using this sql: select c.NOME,c.CPF,e.DATA_CAD ,e.ENFERECO as ENDEREÇO_Atual , sum(f.VALOR) from cli1 as c inner join end1 as e on c.IDCLI1 = e.ID_END…
-
1
votes0
answers34
viewsDoubt with JOINS and GROUP BY in an SQL (Access) query
Thanks for your help. I am not very advanced in SQL and I am facing a difficulty here, is the following: SELECT tbl_afs_pregao.numaf, tbl_items_pregao.nomeitem, Sum(tbl_items_af.qtd) AS SomaDeQtd,…
-
1
votes1
answer101
viewsIs it possible to link tables with keys stored in JSON column?
I have two tables: CREATE TABLE jtable (id integer, jdata JSON); INSERT INTO jtable(id, jdata) VALUES(1, '["1","2","3"]'); INSERT INTO jtable(id, jdata) VALUES(2, '["1","3"]'); INSERT INTO…
-
1
votes0
answers20
viewsQuestions with JOIN [solved]
CREATE TABLE CIDADE( ID_CIDADE INT NOT NULL, NOME VARCHAR(50), CONSTRAINT PK_FORNECEDOR PRIMARY KEY (ID_CIDADE) ); CREATE TABLE FORNECEDOR( CNPJ CHAR(14) NOT NULL, RAZÃO_SOCIAL VARCHAR(40), ENDEREÇO…
-
0
votes0
answers272
viewsInner Join + Where in Mysql
How to use INNER JOIN with WHERE? I’m making a INNER JOIN with 3 tables. I need a WHERE to return only one record. I am trying as follows: SELECT `*` FROM (`tabela1`) INNER JOIN `tabela2` ON…
-
0
votes2
answers175
views -
0
votes0
answers47
viewsHow to use Join, mysql/php
I’m starting with PHP now, and I’d like to know what it’s for and how to use Join, I think it would help solve my problem, but I don’t even know where to start...
-
0
votes2
answers50
viewsJoin does not return the expected
I have the following scheme: tblpessoa with fields: idPessoa, name. tblcity com os campos: idCidade, codCidade, nome, idPessoa(fk da tabela tblpessoa), codigoRegiaoCidade(fk da tabela…
-
0
votes1
answer58
viewsProblem with query Join with 5 tables
Good night, I am trying to make a Join to 5 tables to fetch me the information so that it is not returning me some data. Code SELECT * FROM estabelecimentos INNER JOIN estabelecimentos_anexos ON…
-
0
votes1
answer275
viewsCompare all records in table "A" with each record in table "B"
I am a programmer and rarely use database, I came across an unusual situation of converting multiple files . DBF and save everything in the bank on their respective tables, however some files exceed…
-
0
votes1
answer179
viewsneed to put an extra left Join in this query
My code is below he returns me "h. banks as banks" with a number, which is foreign key I want him to return me to the description of this bank, only that in many cases, h.banco returns me as null…
-
0
votes2
answers764
viewsHow to query data from a table using INNER JOIN in a sub-query in PHP
I have the following SELECT to select data from a table (chat) in a chat system: SELECT * FROM (SELECT * FROM chat WHERE id_chat = '$chat_id' ORDER BY id DESC LIMIT 10) S WHERE id_chat = '$chat_id'…
-
0
votes1
answer27
viewsSelect some data from different tables
Reborn the programmer around here, I’m having trouble with SQL and ask for help. I have two tables called orcamentos and clientes. I need to select all fields in the table orcamentos and only the…
-
0
votes0
answers127
viewsSelect in two fields of a table
Hello, I’m going through a problem and I would like to ask for your help. Here’s the thing: I am integrating a PHP system to the Wordpress Woocommerce plugin and I need to order some products from…
-
0
votes1
answer635
viewsSelect with Join in Codeigniter
I have a question in a select with the use of Join in codeigniter, follows: I have 2 tables. tabela jogo id | id_time1 | id_time2 99 | 1 | 2 tabela time id | time 1 | Real 2 | Barcelona I want to…
-
0
votes1
answer481
viewsCombination of digits from A to Z (Crosse Join)
I’m running a four-digit algorithm from A to Z. I did it using vectors in Pascal like this: var i:integer; j:integer; k:integer; l:integer; vect1:array[1..26] of string; vect2:array[1..26] of…
-
0
votes1
answer516
viewsJOIN between tables with some (s) of them empty
Goodnight I have 6 tables (A,B,C,D,E,F) A tabela A sempre contém registros e tem uma chave primaria ID The other tables B,C,D,E and F are all daughters of table A and have a column FK_ID that…
-
0
votes1
answer457
viewsChamp inconnu error dans on clause - SQL
I have the following situation, with 3 tables: ocorrencias: Has 6 columns: tipo_falha_1 until tipo_falha_6. It’s a two-digit code, from 1 to 20. tipo_falha: Has a description of the faults. The…
-
0
votes1
answer6413
viewsINSERT and INNER JOIN together in Mysql?
Hello is possible to use the INNER JOIN together with the INSERT? I have a table A with 3 columns X, Y and Z and table B with columns W, X and Y and I need to insert in table A the column W of table…
-
0
votes0
answers39
viewsHow to know the total of real estate and the total of photos in an SQL with two INNER JOIN?
I have the following SQL INNER JOIN and would like to know how I can get the total of REAL ESTATE and also the total of PHOTOS, I have already used COUNT(immovel.id) AS TOTAL to know the total of…
-
0
votes2
answers52
viewsSelect from empty data
My code returns all users, checking if they paid the last month, however I connect two tables, one of all customers with the registered payments table, I want to print on jTable even if you have no…
-
0
votes1
answer60
views -
0
votes2
answers98
viewsSelect data from three SQL tables
I am trying to join data from three tables using this sql: SELECT cod_nota, cupom, valor_contrato, valor_cadastro, data_emissao FROM cupons_nota, vendas, notas_fiscais WHERE cupons_nota.cupom =…
-
0
votes1
answer136
viewsCross Table in Mysql
Does anyone know how to implement a Cross Table in Mysql to help me? I need to transform a query that always returns 4 result lines to only 1 row by placing each row field in columns next to each…
-
0
votes1
answer962
viewsView with two or more tables with no link, with different columns and that need to be merged
I have two tables, "PRIMEIRATABLE" with the fields name, surname, and age, another table "SEGUNDATABLE" with the fields name, last_name, and acts the two tables have no link but need to join in a…
-
0
votes1
answer143
viewsLeft Join Slow on Firebird 2.0
I have two tables: Sale > 100 Records Primary key fields: Invoice Payments > 200,000 Records Primary key fields: Id, Invoice, Type, Document. I have the following SQL: Select V.FATURA, P.ID…
-
0
votes1
answer1471
viewsMerge different columns in the same result
I am trying to generate a SELECT in Postgresql that joins columns of different tables in the same column of the result. Example: Usuario ----------------------- | id | nome | regra |…
-
0
votes1
answer15
viewsDisplay prayed results
Good evening I’m creating a referral system, But the query result does not return users with zero indications Here is my select SELECT c.id, c.nome, funcao, area, count(p.cpf_cli) AS quantidade FROM…
-
0
votes1
answer23
viewsJoin in three tables does not show all results
SELECT * FROM produto_unidades join produto_notas on produto_notas.id = produto_unidades.produtoNota_id join produto_licitacoes on produto_licitacoes.id = produto_notas.produtoLicitacoes_id where…