I'm trying to do a query in mysql in several tables at once but the results that I get do not end up serving me.
This is the code I'm using:
SELECT
*,
art.id AS IdArt,
art.nombre AS NombrArt,
conf.Conf1 AS Sexo,
ean.id AS IdEan
FROM 'Articulos' art
INNER JOIN 'Direcciones&Codigos' ean ON art.id = ean.idcosa
INNER JOIN 'Configuraciones' conf ON art.sexo = conf.Conf_id
WHERE UPPER(CONCAT(art.nombre,art.temporada)) LIKE UPPER('%".$buski."%') OR ean.'3' = '".$buski."' OR ean.'4' LIKE UPPER('%".$buski."%') AND 'borrado' = 0
ORDER BY art.temporada DESC, art.material DESC;
Let's see if I can explain exactly what I need. There are 3 different tables. Articles: Where I keep the data of the article. Addresses & codes: Where I keep Ean codes, sizes and colors and reference. Configurations: Where I keep the names of things type Materials, sex, sizes, etc.
Right now, as the query is mounted, I get a mixture of Articles and Codes as results. As each article can have 3000 codes it takes me out of each article 3000 results.
The fact is that I just want to take the result of the article in question, but of course I have to look in directions & codes in case what I'm looking for is the reference or the ean code (which in that case if you take me out only one result). For example, if $ buski = belts that I take out all the results that as a name have belts, not that I take out all that are called belts and all their possible codes.
I have also tried to filter the results with a array_values(array_unique($DAutoCom));
but then I only get a single result.
What can I do so that the array only displays the results of the Articles table?
Let's say that I only have to eliminate all those in the articles table that have the duplicate id and only show one of them.
the loop I build with this:
$R_auto_Articulos = mysqli_query($Conectar, $C_auto_Articulos);
if ($R_auto_Articulos && mysqli_num_rows($R_auto_Articulos)) {
while($row = mysqli_fetch_array($R_auto_Articulos, MYSQLI_ASSOC)) {
that the same thing to show only 1 result per id is done there.