Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Probleme mit JOIN / allg. Syntax

Empfohlene Antworten

Hallo,

wer kann mir bei einem Problem mit einem Statement helfen ? Ich habe drei Tabellen die sich so aufbauen

Tabelle 1: Contact

Contact_id (PK)

Name

Associate_id (FK)

Street

usw.

Tabelle 2: Appointment

Appointment_id (PK)

Contact_id (FK)

Task_id

usw.

Erklärung:

Die Tabelle Contact enthält alle Kundendaten sowie die Information welcher Mitarbeiter für welchen Kunden zuständig ist. (über Associate_id). Die Tabelle Appointment enthält alle Aktivitäten die für Kunden durchgeführt wurden, unter der Task_id verbirgt sich die Art Aktivität (z.B. Meeting).

Ich möchte gerne die Anzahl der der Datensätze ermitteln bei der ein bestimmter Mitarbeiter zuständigt ist (z.B. Nummer 76) und einer bestimmten Aktivität angehört (z.B. 177 für Meeting)

Ich habe es mit einem Select versucht:

select * from crm5.contact where contact_id = (select contact_id from crm5.appointment where task_idx = 177)

doch da kommt die Fehlermeldung: Server: Msg 512, Level 16, State 1, Line 1

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

Also hab ich ein JOIN versucht, allerdings bin ich bei sowas alles andere als fit.:rolleyes:

Hier mein Versuch:

select crm5.contact.contact_id,crm5.Appointment.Appointment_id from crm5.contact, crm5.appointment where crm5.appointment.task_idx = 177 and crm5.contact.associate_id = 76

Dieses Statement scheint syntaktisch auch korrekt zu sein, den der SQL Server (2000 übrigens) nimmt es an. Allerdings arbeitet dieser ca. 20 Minuten lang und produziert mal eben 2,7 Millionen Zeilen. Also hab ich mal wieder einen Bulk-JOIN produziert, oder ?

Kann mir jemand helfen ? Danke im vorraus !

Gruß

Feivel

P.S. Kennt jemand vielleicht auch ein gutes Online tutorial für SQL und/oder im speziellen für JOIN´s ? Ich hab zwar gegoogelt, aber nicht gefunden was mich weitergebracht hat.

  • Autor

Die Lösung für alle die es interessiert:

select c.contact_id,a.contact_id from crm5.contact c, crm5.appointment a where c.contact_id = a.contact_id and a.task_idx = 177 and c.associate_id = 76

:marine

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.