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.

mySQL prüfen ob Feld existiert

Empfohlene Antworten

Veröffentlicht

hallo zusammen,

wie kann ich den mit in mySQL abfragen ob ein Feld mit einem bestimmten Namen in einer bestimmten Tabelle schon exsitiert ??

kann auch eine kombination aus php und SQL sein falls es dafür im SQL keine abfrage gibt.

DANKE

gruß

MadCro

:marine

Hi,

sql weiß ich jetzt auf die schnelle nicht, aber:


$result = mysql_query("select * from table");


for ($i = 0; $i < mysql_num_fields($result); $i++) {

   print "<th>".mysql_field_name($result, $i)."</th>\n";

} 

liefert alle Spaltennamen einer Abfrage, die kannst du dann ja überprüfen.

Gruß Jaraz

hej Jaraz danke Dir für die schnelle Antwort,

Hab es so gelöst , mir war mysql_field_name bis jetzt unbekannt ;o)

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');

$fields = mysql_list_fields("database1", "table1", $link);

$columns = mysql_num_fields($fields);

for ($i = 0; $i < $columns; $i++) {

echo mysql_field_name($fields, $i) . "\n";;

}

Danke

gruß

MadCro

Hallo,

direkt mit einem SQL Statement:

DESCRIBE tabellenname spaltenname

Existiert die Spalte wird sie zurückegegeben ansonsten ist das Ergebnis leer.

Cu

Atreju

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.