Basic SQL Query Help Needed

Basic SQL Query Help Needed

am 26.08.2009 01:21:45 von cool

I have a basic invoice table with related line items table

Goal : I'd like to get ALL the related line items - for ALL the
'open' invoices...

-- this should get a list of open (unpaid) invoices

$query_invoice = "SELECT DISTINCT ID from invoices where status =
'open'"

-------------

-- then I'd like to get ALL the line items - in ALL these 'open'
invoices - so how do I write the next SQL statement :

$query_items = ??? "SELECT ID, NAME from lineitems where --xx???
xx--" ???



Thanks,
cool@hosting4days.com






--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

RE: Basic SQL Query Help Needed

am 26.08.2009 01:40:37 von Martin Gainty

--_633c6927-7aba-462d-ab79-5d9ffef910e5_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


SELECT * FROM ORDER o INNER JOIN ORDER_LINE_ITEMS o_l
ON (o.id=3Do_l.id)
Martin Gainty=20
______________________________________________=20
Verzicht und Vertraulichkeitanmerkung/Note de d=E9ni et de confidentialit=
=E9
=20
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaeng=
er sein=2C so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiter=
leitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient l=
ediglich dem Austausch von Informationen und entfaltet keine rechtliche Bin=
dungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen w=
ir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut =EAtre privil=E9gi=E9. Si vous n'=EAtes=
pas le destinataire pr=E9vu=2C nous te demandons avec bont=E9 que pour sat=
isfaire informez l'exp=E9diteur. N'importe quelle diffusion non autoris=E9e=
ou la copie de ceci est interdite. Ce message sert =E0 l'information seule=
ment et n'aura pas n'importe quel effet l=E9galement obligatoire. =C9tant d=
onn=E9 que les email peuvent facilement =EAtre sujets =E0 la manipulation=
=2C nous ne pouvons accepter aucune responsabilit=E9 pour le contenu fourni=
..




> To: mysql@lists.mysql.com
> From: cool@hosting4days.com
> Subject: Basic SQL Query Help Needed
> Date: Tue=2C 25 Aug 2009 16:21:45 -0700
>=20
> I have a basic invoice table with related line items table
>=20
> Goal : I'd like to get ALL the related line items - for ALL the =20
> 'open' invoices...
>=20
> -- this should get a list of open (unpaid) invoices
>=20
> $query_invoice =3D "SELECT DISTINCT ID from invoices where status =3D =20
> 'open'"
>=20
> -------------
>=20
> -- then I'd like to get ALL the line items - in ALL these 'open' =20
> invoices - so how do I write the next SQL statement :
>=20
> $query_items =3D ??? "SELECT ID=2C NAME from lineitems where --xx???=20
> xx--" ???
>=20
>=20
>=20
> Thanks=2C
> cool@hosting4days.com
>=20
>=20
>=20
>=20
>=20
>=20
> --=20
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dmgainty@hotmail.c=
om
>=20

____________________________________________________________ _____
With Windows Live=2C you can organize=2C edit=2C and share your photos.
http://www.windowslive.com/Desktop/PhotoGallery=

--_633c6927-7aba-462d-ab79-5d9ffef910e5_--