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.

MSSQL und DISTINCT

Empfohlene Antworten

Veröffentlicht

Hi,

ich habe einen MSSQL Server und in einer Spalte stehen immer 5stellige Zahlen.

Ich möchte jetzt einfach alle verschiedenen Zahlen auflisten.

Mein Problem ist das er den DISTINCT Befehl nicht kennt.

heisst der vielleicht anderst oder gibts den überhaupt nicht ???

SELECT DISTINCT test FROM testtabelle

Gruß Scratch

aus MS SQL Server 2000 msdn:


Distinct
Gibt eine Menge zurück, wobei doppelte Tupel aus einer angegebenen Menge entfernt werden.

Syntax
Distinct(«Set»)

Hinweise
Doppelte Werte werden vom Ende her gelöscht.

Beispiel
Das folgende Beispiel gibt {(a,, (c,d )} zurück:

Distinct({(a,, (c,d), (a,})


[/PHP]

Richtig:

DISTINCT klappt aufm MSSQL Server

Original geschrieben von Scratch

SELECT DISTINCT test FROM testtabelle

Das geht so ansich schon und wenns bei dir so nicht klappt, dann solltest sagen was genau nicht klappt, bzw. was bei deiner Abfrage rauskommt.

Goos

  • Autor

Warning: odbc_execute(): SQL error: [Microsoft][ODBC SQL Server Driver]Der Cursortyp wurde geändert, SQL state 01S02 in SQLExecute in test.php on line 48


include("start.php");

$anfrage = "SELECT DISTINCT test FROM testtabelle";

$result = odbc_prepare($odbcdb,$anfrage);
odbc_execute($result); // <-------------- LINE 48

while($zeile = odbc_fetch_array($result))
{
echo $zeile["test"] . "<br>";
}

odbc_close($odbcdb);
[/PHP]

im PHPForum konnte mir keiner helfen :-(

Original geschrieben von Scratch

Warning: odbc_execute(): SQL error: [Microsoft][ODBC SQL Server Driver]Der Cursortyp wurde geändert, SQL state 01S02 in SQLExecute in test.php on line 48


include("start.php");

$anfrage = "SELECT DISTINCT test FROM testtabelle";

$result = odbc_prepare($odbcdb,$anfrage);
odbc_execute($result); // <-------------- LINE 48

while($zeile = odbc_fetch_array($result))
{
echo $zeile["test"] . "<br>";
}

odbc_close($odbcdb);
[/PHP]

im PHPForum konnte mir keiner helfen :-( [/b]

also ich kenne nicht php, aber es hat überhaupt nichts mit dem distinct zutun !!

Nimm einfach den SQL Stetment und für direkt auf dem Server aus dann wirst Du sehen, dass distinct und SQL Server passen zusammen ;)

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.