PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > What should be a simple query...
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
What should be a simple query...

Réponse
 
LinkBack Outils de la discussion
Vieux 11/09/2007, 04h36   #1
Mike Mannakee
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut What should be a simple query...

I have two tables, one called RMAs and the other called rma_line_items. The
first one has the general details of the RMA (Return Merchandise
Authorization) , the second holds the details of each item being returned.

What I want is a listing of the RMA ids (which are unique in the RMAs table)
which have more than one line item in the corresponding table. So I'm
using:

SELECT * FROM RMAs, rma_line_items
WHERE TO_DAYS(date_settled) = 733274
AND RMAs.rma_id IN
(SELECT rma_id FROM rma_line_items HAVING COUNT(*) > 1)

and it's netting me nothing, which I know is not true. So to investigate I
just ran the subselect:

SELECT rma_id FROM rma_line_items HAVING COUNT(*) > 1

and I find it's not giving me but one row, the first one to match having
more than one item. But there are plenty more RMAs that have more than one
entry in the rma_line_items table and I need to get at them.

What am I doing wrong? Any ideas?

Mike


  Réponse avec citation
Vieux 11/09/2007, 08h23   #2
David Schneider-Joseph
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What should be a simple query...

Try this:

SELECT RMAs.rma_id FROM RMAs, rma_line_items
WHERE TO_DAYS(date_settled) = 733274
AND RMAs.rma_id = rma_line_items.rma_id
GROUP BY RMAs.rma_id HAVING COUNT(*) > 1

On Sep 10, 2007, at 11:36 PM, Mike Mannakee wrote:

> I have two tables, one called RMAs and the other called
> rma_line_items. The
> first one has the general details of the RMA (Return Merchandise
> Authorization) , the second holds the details of each item being
> returned.
>
> What I want is a listing of the RMA ids (which are unique in the
> RMAs table)
> which have more than one line item in the corresponding table. So I'm
> using:
>
> SELECT * FROM RMAs, rma_line_items
> WHERE TO_DAYS(date_settled) = 733274
> AND RMAs.rma_id IN
> (SELECT rma_id FROM rma_line_items HAVING COUNT(*) > 1)
>
> and it's netting me nothing, which I know is not true. So to
> investigate I
> just ran the subselect:
>
> SELECT rma_id FROM rma_line_items HAVING COUNT(*) > 1
>
> and I find it's not giving me but one row, the first one to match
> having
> more than one item. But there are plenty more RMAs that have more
> than one
> entry in the rma_line_items table and I need to get at them.
>
> What am I doing wrong? Any ideas?
>
> Mike
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?
> unsub=david@davidsj.com
>
>


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h36.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07482 seconds with 10 queries