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
-
2
votes1
answer100
viewsGenerate a table from another 5
I need help to build a query that brings data from 5 other tables. I will try to be as clear as possible, in case information is lacking, please inform me. Come on: I have the Midias table:…
-
2
votes1
answer257
viewsCrystal Report with LEFT JOIN and WHERE
I’m having a problem making one LEFT JOIN in Crystal Reports. From what I’ve researched, it’s a classic SQL problem when using criteria WHERE crossing with the LEFT JOIN. I tried to solve every way,…
-
2
votes1
answer1120
viewsRetrieve data from fields of the same name but from different tables
I have a select that looks for data from three different tables, but has some common fields between these three tables. My question is how to get the data of these fields, which has the common name…
-
2
votes2
answers40109
viewsGet values from one table that are not contained in another
I would like to know how I can get values from a mysql database and the data obtained should be in one table and not in another. For example: I want all equipment (equipment table) that is not…
-
2
votes1
answer1215
viewsEdit records of a field clientdataset from a Join
I have a simple example, but in three layers, with sqldataset + datasetprovider + clientdataset. I do not load any field in sqldataset. In datasetprovider I leave the updatemode in upwherekeyonly.…
-
2
votes1
answer32
viewsSQL Server 2012, doubts
Based on the attached table, could you tell me if the resolution of the exercise below is correct? Show orders that have items that were sold at a discount (discount occurs when the sale price -…
-
2
votes2
answers923
viewsMerge table using a Subquery
I have 3 tables: inscricaoaluno, inscricaoescola and prova, with the following structures: PROOF IDPROVA | DESCPROVA | TYPE | QTDEMAX ENROLLED TEACHER | SCHOOL(IDESCOLA) | DTINSCRICAO | IDPROVA…
-
2
votes1
answer905
views -
2
votes1
answer400
viewsAdd records with type
I have 2 tables linked by id and need to add a field in table 2 grouping through a field in table 1 -----TABELA 1----- ID_tab1 - tipo_pgto -----TABELA 2----- ID_tab2 - ID_tab1 - valor_pago I want…
-
2
votes1
answer187
viewsINNER JOIN performance in SQL
Hello, would anyone know me if there is any significant difference in performance in the two ways of doing INNER JOIN below? Way 1: SELECT column_name(s) FROM table1 INNER JOIN table2 ON…
-
2
votes2
answers292
viewsHow to reuse a pthreads?
I’m using pthread.h and using the following functions: // // Cria A thread // thread_argsPP[contthreadsPP] = contthreadsPP; pthread_create(&threadsPP[contthreadsPP], NULL, ReceivePinPad, (void…
-
2
votes1
answer346
viewsNumber of lines increases after use of JOIN
Hello, I’m new to SQL and I’m having a doubt. As in the example below, I wanted to take from a table 'b' the description of the code present in table 'a'. But the number of rows in table 'a' when I…
-
2
votes1
answer160
viewsINNER JOIN with Where
I have the following tables : permissions_users id_user id_permissao permissions - id - permission I have a session variable where I have the id of user , I need to do a table search for id and…
-
2
votes1
answer80
viewsCount records only if larger than the current datetime, with Count()
I have the following query: SELECT u.nome, u.email, u.login, u.data_cadastro, COUNT(*) AS qtd FROM patrocinadores AS p LEFT JOIN anuncios AS a ON a.id_user = p.id_user INNER JOIN usuarios AS u ON…
-
2
votes1
answer63
viewsError in SQL statement
I have the following comic: When I run the following Query: SELECT tbCelula.* FROM (((tbTiposMonitorizacao INNER JOIN tbMonitorizacaoProj ON tbTiposMonitorizacao.TM_ID = tbMonitorizacaoProj.MP_T_ID)…
-
2
votes2
answers828
viewsHow to differentiate data from two tables with columns of equal names in an SQL request with JOIN?
I combined record of two tables using JOIN, the two tables have some columns with equal names... When extracting data with PHP how will I differentiate ? Example : foreach($dados as $values){ echo…
-
2
votes2
answers879
viewsPHP - How to make left Join with more than one record in the other tables not return repeated values in the columns?
I need to perform an SQL query in PHP, where I need to create a table from 9 other tables, joining all the columns with a LEFT JOIN, and with the 'Client' field as key between the tables. However,…
-
2
votes1
answer1233
viewsLeft Outer Join does not bring Null values
I have two tables: formulario_campo ( cod_campo, descricao, cod_formulario ) Filled with the following values - input_nome, Nome, 1 - input_sexo, Sexo, 1 The second table: —…
-
2
votes1
answer160
viewsLEFT Outer Join does not work on LINQ when 0 is the reference? null only
I’m having doubts on Left Outer Join, I’m using MVC 5 C#, Net 4.5.2. I have the following Model Fornecedor public class fechamentoFornecedor { public int FornecedorId { get; set; } public int Tipo {…
-
2
votes1
answer158
viewsSQL - How to make multiple Inserts in a table with the result of a SELECT * of another table in a query
Hello, I would like to know how to make several Inserts in a table with the result of a SELECT of all id of another table table that are not as foreign key in the first table. I already have the…
-
2
votes4
answers3541
viewsHow to bring records of a LEFT JOIN even if not obeying the WHERE?
Exemplifying, I have the tabela_A: cod nome 1 stack 2 overflow 3 stackoverflow and tabela_B: cod_tabela_A ano mes valor 1 2016 1 100 1 2016 2 115 2 2016 1 90 When made a LEFT JOIN, returns me the…
-
2
votes1
answer1411
viewsSelect with Inner June too slow
I have a problem where select is bringing the right result, but taking too long. Follow select : SELECT c.cod_paciente, p.nome, i.valor, i.quantidade, d.convenio, c.cod_conta FROM caddadosclinico d…
-
2
votes3
answers3385
views2 COUNT within a SELECT with LEFT JOIN
I have two tables: users: id | nome | email shipments: id | id_envia | id_recebe Every time a user sends a card (which goes by email) to another user, mark this table, and every time they receive…
-
2
votes2
answers91
viewsJoin in array creating elements?
We can imagine the following array: var arr = ["a", "b", "c", "d"]; I know I can use the join(", ") to turn it into a type string: "a, b, c, d", but I would like to create an element for each item…
-
2
votes1
answer143
viewsMake a SELECT multiple tables and save to a spreadsheet
I’m trying to make a SELECT with multiple tables, where I have a product with your information, and I have another table structure to be able to add an extra field and its information. What I tried…
-
2
votes2
answers1684
viewsSelect with INNER JOIN, bringing fields that have NULL foreign key
I have a table items, requested items, interested (she has self relationship, is used for secretariat, sector and employee, and a table requested), in the table requested I have 3 foreign keys (one…
-
2
votes2
answers360
viewsCorrect way to make a great Inner Join
Good morning, you guys. I’m a beginner in php and I’m developing a program for controlling file boxes. I have a database in which the table "box" is the main one, it has several references to other…
-
2
votes1
answer579
views -
2
votes1
answer508
viewsPass lambda statement by parameter - C# - Entity
I have a method in which I need to pass only one select per parameter: public List<TEntity> GetAll(Expression<Func<TEntity, TEntity>> Select) { var query =…
-
2
votes2
answers666
viewsDELETE WITH LEFT JOIN
I’m having an error trying to execute this command: DELETE doacoes FROM doacoes LEFT OUTER JOIN animais ON animais.idAnimal = doacoes.idAnimalDoacao WHERE animais.idAnimal = doacoes.idDoacao; I want…
-
2
votes1
answer192
viewsMYSQL - Select 2 tables
Good morning Personal! I have a problem when performing a query in MYSQL, and the query I am using is not displaying the desired results. Follow the example: TABLE: CLIENTES (codigo_cliente, nome,…
-
2
votes2
answers186
viewsHow to select single data from a Join conditional?
I have 2 database tables: Servers +----------+--------------+ | Field | Type | +----------+--------------+ | id | int(11) | | ip | varchar(255) | | votes | int(11) | | port | varchar(255) | | hash |…
-
2
votes2
answers49
viewsHow do I list all fields from one table plus a random value from another table?
I’m having a problem making the relationship with two tables, tb_adm_anuncios and tb_adm_anuncio_banner. For each ad I have 4 banners, and to list these ads I need: **Anúncio:** -Nome do Anúncio…
-
2
votes2
answers116
viewsDifficulty returning the result in a single query without duplicating
I am trying to assemble a query (MYSQL) to return me all the clients that a particular seller can view. The rules to show the list of customers for this seller are: - Customers with contracts…
-
2
votes3
answers86
viewsProblems with SELECT RIGHT JOIN
I have two tables, A and B. Na Table A, I have a column with names of machines (Cutter, Baler, Packer and Rewinder) and in the other column some causes that made them stop (As Lack of Electrical…
-
2
votes2
answers650
viewsProblem with Mysql Inner Join
I’m trying to create a query to bring results that are in different tables in the Mysql,3 but I’m not getting it. I have experience in JOIN in the SQL, but I’m picking up a little bit to do in the…
-
2
votes1
answer51
viewsTable consultation with CONCAT and JOIN?
I need to get a collection as a result of consultation on 3 tables using concat and join, the image below shows the relationship between them: I tried using the code below $teste =…
-
2
votes1
answer217
viewsSQL JOIN multiple tables
I have 4 tables that I need to extract the results, but I always get duplicate records, someone can help? tabclientes: codcli nome 1 A 2 B 3 C tabrepre: codrepre nome 1 AA 2 AB 3 AC tabvendedor:…
-
2
votes3
answers98
viewsWith LEFT JOIN list the NOT IN
In Mysql I have the table usuario, with the fields ID and CPF: I received from the client a list with some numbers and what I need: See which of these users is NOT in the table…
-
2
votes1
answer194
viewsScript to determine a desired column
Good morning! I’m trying to make a script where doing 2 joins, it shows me 3 columns. I mean, what I want is to get the email do lider. However it does not have a specific column, it is inserted…
-
2
votes1
answer175
viewsSelf Join subquery approach
I have a attendance list table, where I need a list identifying who was present: Table structure: create table lista_presenca_usuario ( id int identity(1,1), usuarioId int, dia int, turno int,…
-
2
votes1
answer24
viewsHow to find time-series loopholes?
I have several time series with gaps. I mean, day has observation, spends a few days without, then back to observe and so continues with holes. The problem is that they put these series together in…
-
2
votes0
answers46
viewsHow to group data in R?
I wonder if it has any function in the R that makes it possible to make a kind of "grouping" of the data. For example, a way to get this spreadsheet to return something like: Codigo Grupo Qtde Total…
-
1
votes3
answers1494
viewsFilter table before applying a LEFT JOIN
I have two tables and I want all the elements of the first - regardless of the condition of JOIN (which characterizes a LEFT JOIN) - but before that I want to filter the second table. For example:…
-
1
votes1
answer7134
viewsError: Multi-part identifier could not be associated
I’m trying to execute the following command: SELECT * FROM pendencia, cliente LEFT JOIN servico ON pendencia.id_pendencia = servico.id_pendencia LEFT JOIN cidade ON cliente.id_cidade =…
-
1
votes1
answer214
viewsUsing Left Join on Datatable Server-Side
After several attempts, I still haven’t been able to implement a 100% left Join within the Datatable Server-Side Note, the following code works 100% HTML <table id="datatable_fixed_column"…
-
1
votes1
answer84
viewsProblem with LEFT Joins joins and one condition
I have had this problem for some time. I count on your help. I have 3 tables: publicacao id cartaz titulo 1 eradogelo.jpg A Era do gelo 2 ojogo.jpg O Jogo 3 helpme.jpg Help Me 4 please.jpg Please 5…
-
1
votes3
answers565
viewsRepeat LEFT JOIN with other parameters in the same query
I have 2 tables: FATHER: id nome SON: id idpai sexo_filho I wanted to make a SELECT that adds up the amount of children male and female, that’s the problem, I can only do with one of the sex: SELECT…
-
1
votes1
answer136
viewsDisplaying null results for mysql related tables
I need to create a relational query that returns records containing data from both the PERMISSAO table and the USUARIOS table. ALL PERMISSIONS records must be displayed. When there are no USER…
-
1
votes2
answers1283
viewsInner Join table with multiple identical Ids
The problem is this, I have two tables one of contracts and another of 1xN borrowers and when I do the inner join it repeats exactly the amount of columns I have in borrower but only bears the name…