Doublon sql
onpouce
-
P@t@ch0n Messages postés 603 Statut Membre -
P@t@ch0n Messages postés 603 Statut Membre -
Salut tout le monde,
voila mon souci , j'ai une requete sql qui m'affiche plus de 600 foi la meme ligne alors que dans ma table elle n'y est qu'une foi.
j'ai des jointure et un order by c'est tout.
Quelqu'un a t'il deja eu ce souci ? ou sais comment le résoudre ?
merci davance ++
voila mon souci , j'ai une requete sql qui m'affiche plus de 600 foi la meme ligne alors que dans ma table elle n'y est qu'une foi.
j'ai des jointure et un order by c'est tout.
Quelqu'un a t'il deja eu ce souci ? ou sais comment le résoudre ?
merci davance ++
A voir également:
- Doublon sql
- Doublon photo - Guide
- Logiciel sql - Télécharger - Bases de données
- Supprimer doublon excel - Guide
- Jointure sql ✓ - Forum MySQL
- Sql (+) - Forum Programmation
6 réponses
Hum, pourrais-tu montrer la requete générée par php ?
C'est à dire en faisant un echo du sql.
C'est à dire en faisant un echo du sql.
ba en fait je n'arive pas a lafficher ^^ car il y a plus de 1M de ligne donc je l'ai afficher juste une foi grace a phpmyadmin et ca retourne par exemple:
Monsieur machin adress te truc truc2 truc3 ...
Monsieur machin adress te truc truc2 truc3 ...
Monsieur machin adress te truc truc2 truc3 ...
Monsieur machin adress te truc truc2 truc3 ...
Monsieur machin adress te truc truc2 truc3 ...
et ca plus de 600 fois
apré ca passe a la deuxieme vrai ligne :
Monsieur machin2 adress2 te2 truc truc2 truc3 ...
Monsieur machin2 adress2 te2 truc truc2 truc3 ...
Monsieur machin2 adress2 te2 truc truc2 truc3 ...
Monsieur machin2 adress2 te2 truc truc2 truc3 ...
Monsieur machin2 adress2 te2 truc truc2 truc3 ...
pareil plus de 600 fois
Monsieur machin adress te truc truc2 truc3 ...
Monsieur machin adress te truc truc2 truc3 ...
Monsieur machin adress te truc truc2 truc3 ...
Monsieur machin adress te truc truc2 truc3 ...
Monsieur machin adress te truc truc2 truc3 ...
et ca plus de 600 fois
apré ca passe a la deuxieme vrai ligne :
Monsieur machin2 adress2 te2 truc truc2 truc3 ...
Monsieur machin2 adress2 te2 truc truc2 truc3 ...
Monsieur machin2 adress2 te2 truc truc2 truc3 ...
Monsieur machin2 adress2 te2 truc truc2 truc3 ...
Monsieur machin2 adress2 te2 truc truc2 truc3 ...
pareil plus de 600 fois
C'est pas le résultat de la requete que je te demandais, mais le SQL de la requete, mais sans concaténation et variable, bref avec les valeurs.
Toujours est-il qu'il y a quelquechose qui cloche ici.
... left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s ...
Toujours est-il qu'il y a quelquechose qui cloche ici.
... left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s ...
ba oki mais ca change rien ce sont que des variables ...
select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total
from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s
left join orders_etape simon on (ot.orders_id = simon.orders_id), products_to_categories c
left join products cc on (c.products_id=cc.products_id)
where o.orders_status = s.orders_status_id and s.language_id = '4' and s.orders_status_id<>'13' and s.orders_status_id<>'5' and ot.class = 'ot_total' and simon.etape2= '1' and simon.etape3= '1' and simon.etape4= '0' and simon.etape5= '0' and o.orders_options != '4' AND o.orders_options != '6' AND o.orders_options != '12' AND o.orders_options != '20' AND o.orders_options != '14' AND o.orders_options != '22' AND o.orders_options != '28' AND o.orders_options != '30' and c.categories_id ='45' order by o.last_modified LIMIT 0 , 30
voila
select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total
from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s
left join orders_etape simon on (ot.orders_id = simon.orders_id), products_to_categories c
left join products cc on (c.products_id=cc.products_id)
where o.orders_status = s.orders_status_id and s.language_id = '4' and s.orders_status_id<>'13' and s.orders_status_id<>'5' and ot.class = 'ot_total' and simon.etape2= '1' and simon.etape3= '1' and simon.etape4= '0' and simon.etape5= '0' and o.orders_options != '4' AND o.orders_options != '6' AND o.orders_options != '12' AND o.orders_options != '20' AND o.orders_options != '14' AND o.orders_options != '22' AND o.orders_options != '28' AND o.orders_options != '30' and c.categories_id ='45' order by o.last_modified LIMIT 0 , 30
voila
j'ai oublié de dire que sans ce qui est souligné ca marche très bien....
select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total
from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s
left join orders_etape simon on (ot.orders_id = simon.orders_id), products_to_categories c
left join products cc on (c.products_id=cc.products_id)
where o.orders_status = s.orders_status_id and s.language_id = '4' and s.orders_status_id<>'13' and s.orders_status_id<>'5' and ot.class = 'ot_total' and simon.etape2= '1' and simon.etape3= '1' and simon.etape4= '0' and simon.etape5= '0' and o.orders_options != '4' AND o.orders_options != '6' AND o.orders_options != '12' AND o.orders_options != '20' AND o.orders_options != '14' AND o.orders_options != '22' AND o.orders_options != '28' AND o.orders_options != '30' and c.categories_id ='45' order by o.last_modified LIMIT 0 , 30
select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total
from orders o left join orders_total ot on (o.orders_id = ot.orders_id), orders_status s
left join orders_etape simon on (ot.orders_id = simon.orders_id), products_to_categories c
left join products cc on (c.products_id=cc.products_id)
where o.orders_status = s.orders_status_id and s.language_id = '4' and s.orders_status_id<>'13' and s.orders_status_id<>'5' and ot.class = 'ot_total' and simon.etape2= '1' and simon.etape3= '1' and simon.etape4= '0' and simon.etape5= '0' and o.orders_options != '4' AND o.orders_options != '6' AND o.orders_options != '12' AND o.orders_options != '20' AND o.orders_options != '14' AND o.orders_options != '22' AND o.orders_options != '28' AND o.orders_options != '30' and c.categories_id ='45' order by o.last_modified LIMIT 0 , 30
Bah, oui, tu faisune jointure non normalisé de jointure, normal d'obtenir un tel résultat.
Tu dois spécifier la condition de jointure pour products_to_categories.
Ah et essaie de mettre les mots clefs en majuscule, et de faire des retours à la ligne dans la chaine de tes requetes, c'est quand meme plus lisible.
Tu dois spécifier la condition de jointure pour products_to_categories.
Ah et essaie de mettre les mots clefs en majuscule, et de faire des retours à la ligne dans la chaine de tes requetes, c'est quand meme plus lisible.
SELECT o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total FROM orders o LEFT JOIN orders_total ot ON o.orders_id = ot.orders_id, orders_status s LEFT JOIN orders_etape simon ON ot.orders_id = simon.orders_id LEFT JOIN products_to_categories c ON ?????????????????????? LEFT JOIN products cc ON c.products_id=cc.products_id WHERE o.orders_status = s.orders_status_id AND s.language_id = '4' AND s.orders_status_id NOT IN(13, 5) AND ot.class = 'ot_total' AND simon.etape2= '1' AND simon.etape3= '1' AND simon.etape4= '0' AND simon.etape5= '0' AND o.orders_options NOT IN(4, 6, 12, 20, 14, 22, 28, 30) AND c.categories_id ='45' ORDER BY o.last_modified LIMIT 0 , 30
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Non, tu ne l'as pas fait pour products_to_categories avec les autres tables.
La virgule signifie une jointure.
La virgule signifie une jointure.
humm oui oki mais ca on est d'accord j'ai le droit de l'ecrire non ??
SELECT o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text AS order_total
FROM orders o, products_to_categories c , orders_status s
LEFT JOIN orders_total ot ON ( o.orders_id = ot.orders_id )
LEFT JOIN orders_etape simon ON ( ot.orders_id = simon.orders_id )
WHERE o.orders_status = s.orders_status_id
AND s.language_id = '4'
AND s.orders_status_id != '13'
AND s.orders_status_id != '5'
AND ot.class = 'ot_total'
AND simon.etape2 = '1'
AND simon.etape3 = '1'
AND simon.etape4 = '0'
AND simon.etape5 = '0'
AND o.orders_options NOT INT ('4', '6', '12', '20', '14', '22', '28', '30')
ORDER BY o.last_modified
SELECT o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text AS order_total
FROM orders o, products_to_categories c , orders_status s
LEFT JOIN orders_total ot ON ( o.orders_id = ot.orders_id )
LEFT JOIN orders_etape simon ON ( ot.orders_id = simon.orders_id )
WHERE o.orders_status = s.orders_status_id
AND s.language_id = '4'
AND s.orders_status_id != '13'
AND s.orders_status_id != '5'
AND ot.class = 'ot_total'
AND simon.etape2 = '1'
AND simon.etape3 = '1'
AND simon.etape4 = '0'
AND simon.etape5 = '0'
AND o.orders_options NOT INT ('4', '6', '12', '20', '14', '22', '28', '30')
ORDER BY o.last_modified
select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total
from " . TABLE_ORDERS . " o
left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s
left join ".TABLE_ORDERS_ETAPE." simon on (ot.orders_id = simon.orders_id), products_to_categories c
left join products cc on (c.products_id=cc.products_id)
where o.customers_id = '" . (int)$cID2 . "' and s.orders_status_id<>'13' and s.orders_status_id<>'5' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' and simon.etape2= '1' and simon.etape3= '1' and simon.etape4= '0' and simon.etape5= '0' and o.orders_options != '4' AND o.orders_options != '6' AND o.orders_options != '12' AND o.orders_options != '20' AND o.orders_options != '14' AND o.orders_options != '22' AND o.orders_options != '28' AND o.orders_options != '30' and c.categories_id ='45' order by o.last_modified LIMIT 0 , 30
merci de m'aider