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.

insert... select für Tabelle mit Fremdschlüsseln

Empfohlene Antworten

Veröffentlicht

Hallo zusammen, stehe etwas aufm Schlauch und brauche mal Erleuchtungshilfe.

Datenbank: MySQL, ENGINE = InnoDB

Folgende Tabellen seien gegeben:

tb1(id_tb1, nummerierung, text_tb1) Tabelle enthält viele Datensätze.

tb2(id_tb2, text_tb2) Tabelle enthält 3 Datensätze und die Werte für id_tb2 betragen 1, 2, 3.

In einer 3. Tabelle möchte ich Atribute daraus einander zuweisen, Aufbau sei (fk = Foreign Key, verweist auf die ID's von tb1 und tb2):

tb3(fk_tb1 (not null), fk_tb2 (not null))

Für die Zuweisung habe ich (zuletzt) folgende insert-Anweisung versucht:

insert into tb3(fk_tb1)

SELECT id_tb1 from tb1, ---- Alle Inhalte aus id_tb1 sollen übernommen werden. Dann sollen diese je nach Wert verschiedene Zuweisungen in der nebigen Spalte fk_tb2 erhalten (diese muss ich gleich mit befüllen, da sie ja nicht NULL sein darf): ------

SET fk_tb2 = "1" WHERE fk_tb1 < 19,

SET fk_tb2 = "2" WHERE fk_tb1 > 18 AND fk_tb1 < 37,

SET fk_tb2 = "3" WHERE fk_tb1 > 36;

Ich bekomme immer wieder Fehlermeldungen, dass die Syntax verkehrt ist - und nu hab ich langsam Hirnsausen und würde mich über Eure Hilfe freuen.

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.