Updating
After discussion in the comments of this reply, it is clear that your query is not returning results as by inserting the records into the database you are not applying to the field tb_trabalhador_id
of your table tb_detalhe_trabalhador
the value entered in the field id
of your table tb_trabalhador
.
With the exception of the typing error in the table name I mentioned in the "original answer", your query is well constructed and does not return results unless there are no results related by the fields indicated in it.
Original Response
Your query is in condition and well formatted, but I think you have a typo in the table name:
Tb_trabalhador
It should be with t
minuscule:
tb_trabalhador
Or vice versa.
Consultation:
SELECT *
FROM tb_trabalhador
INNER JOIN tb_detalhe_trabalhador ON tb_trabalhador.id = tb_detalhe_trabalhador.tb_trabalhador_id
9.2.2 Identifier Case Sensitivity
In Mysql, Databases correspond to Directories Within the data directory. Each table Within a database Corresponds to at least one file Within the database directory (and possibly more, Depending on the Storage engine). Consequently, the case sensitivity of the underlying Operating system plays a part in the case sensitivity of database and table Names. This Means database and table Names are not case sensitive in Windows, and case sensitive in Most Varieties of Unix. One notable Exception is Mac OS X, which is Unix-based but uses a default file system type (HFS+) that is not case sensitive. However, Mac OS X also Supports UFS volumes, which are case sensitive just as on any Unix.
That translated:
In Mysql, the databases correspond to the directories within the data directory. Each table within a database corresponds to at least one file in the database directory (and possibly more, depending on the storage engine). Consequently, the sensitivity of the underlying operating system to upper or lower case letters plays a role in the sensitivity of upper or lower case letters in database and table names. This means that database and table names are not case-sensitive in Windows, but are in most varieties of Unix. A notable exception is Mac OS X, which is based on Unix, but uses a standard file system type (HFS+), which does not differentiate case from case. However, Mac OS X also supports UFS volumes, which are sensitive, just like on any Unix.
Your query is in condition, if no result is returned it is because there is no ID to make the connection. Have you checked if there are any records related by that field?
– Zuul
Right in the bank this query returns some line?
– rray
my test is done in the Database before being placed in php code. The result is blank
– ChrisAdler
Post the structure of the two tables involved, it is easier to help. Are you sure that the tb_worker detail table has a tb_worker name field ?
– Bacco
I have now changed the code with the table structure
– ChrisAdler
Place a print of the result of your database. The only thing is that there may be no relationship between the tables.
– lionbtt
Based on the comments in my reply, your problem seems to be another one relating to the insertion of data, not the collection of data. I suggest you open up a new question to deal with.
– Zuul
Two questions: 1. there are data on
tb_detalhe_trabalhador
? and 2. the foreign key is correctly configured?– Rodrigo Rigotti