MySQL Forums
Forum List  »  German

Re: Nicht bezahlte Beiträge ermitteln
Posted by: Hauke Betz
Date: May 28, 2007 11:40PM

Hallo,

versuch es mit einem UNION. Das Statement würde in etwa wie folgt lauten (Habe es allerdings nicht getestet):

SELECT CONCAT_WS(' - zuletzt bezahlt am - ', CONCAT_WS(' ', client.nname, client.vname), DATE_FORMAT(date, '%d.%m.%Y'))
FROM bookings AS book, clients AS client
WHERE book.date <= DATE_SUB( CURDATE(), INTERVAL 12 MONTH) AND book.client_id = client.id
UNION
SELECT CONCAT_WS('NV', CONCAT_WS(' ', cl.nname, cl.vname), DATE_FORMAT('2005-01-01, '%d.%m.%Y')), FROM clients as cl
LEFT JOIN bookings as bo on bo.client_id = cl.id
WHERE bo.client_id = null;

Da das Datumsfeld nicht aus der Tabelle Clients stammt, muss man noch ein wenig "basteln", wie etwa durch einen Dummy (DATE_FORMAT('2005-01-01','%d.%m.%Y')) ersetzen.

Gruß

Hauke

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Nicht bezahlte Beiträge ermitteln
2287
May 28, 2007 11:40PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.