Visualizzazione dei risultati da 1 a 6 su 6

Discussione: Errore sintassi query

  1. #1

    Errore sintassi query

    Ciao,
    ho la seguente subroutine:+

    Sub DisplayScrollNewsLinks(iTop, iCategory)
    Dim oCn, oRs, rSQL
    Dim titreNews, texteNews, dateNews, sCategory, sTitleCat

    Set oCn = DBConnexion(DB_MAIN)

    If iCategory <> "" and iCategory <> 0 Then
    sCategory = "?cat=" & iCategory
    rSQL = "SELECT cTitle FROM categories WHERE cID=" & iCategory
    Set oRs = DBRecordSet(oCn, rSQL)
    If Not oRs.EOF Then sTitleCat = " - " & Server.HTMLEncode(oRs(0))
    End If

    rSQL = rSQL & "SELECT TOP " & iTop & " nID, nDate, nTitle FROM news, "
    rSQL = rSQL & "versions WHERE nVersion=vID AND nDate < '" & DateTimeToString(Now()) & "' "
    rSQL = rSQL & "AND nValid=1"
    If sCategory <> "" Then rSQL = rSQL & " AND nCategory=" & iCategory
    rSQL = rSQL & " ORDER BY nDate DESC"

    Set oRs = DBRecordSet(oCn, rSQL)


    If Not oRs.EOF Then
    While Not oRs.EOF
    Response.Write "<span class=""rm"">" & GetDateLitteralDDMMYYYY(StringToDate(oRs("nDate")) ) & "</span>-" & vbCRLF
    Response.Write "" & CodeMessage(oRs("nTitle"), False) & "" & vbCRLF
    oRs.MoveNext
    WEnd
    Else
    Response.Write GetTranslation("LANG_EMPTY_SECTION")
    End If


    oCn.Close
    Set oCn = Nothing
    Set oRs = Nothing
    End Sub
    'End Display the top news list (links to news)


    Quando la uso con MySQL viene restituito un errore di sintassi della query


    rSQL = rSQL & "SELECT TOP " & iTop & " nID, nDate, nTitle FROM news, "
    rSQL = rSQL & "versions WHERE nVersion=vID AND nDate < '" & DateTimeToString(Now()) & "' "
    rSQL = rSQL & "AND nValid=1"
    If sCategory <> "" Then rSQL = rSQL & " AND nCategory=" & iCategory
    rSQL = rSQL & " ORDER BY nDate DESC"


    Dove può essere l'errore?

    Saluti,
    carlostefano

  2. #2
    Utente di HTML.it L'avatar di wallrider
    Registrato dal
    Apr 2003
    Messaggi
    2,755
    ci credo, mysql non conosce TOP
    devi usare LIMIT
    RIP Cicciobenzina 9/11/2010

    "Riseminaciceli, i ceci nell'orto"

  3. #3
    LIMIT e TOP hanno la stessa identica funzione?

  4. #4
    Utente di HTML.it L'avatar di wallrider
    Registrato dal
    Apr 2003
    Messaggi
    2,755
    limit è più potente:
    mentre TOP serve a prendere n records, limit serve a prendere n records a partire da j !
    Comunque informati sulla sintasi perchè sono secoli che non lo uso
    RIP Cicciobenzina 9/11/2010

    "Riseminaciceli, i ceci nell'orto"

  5. #5
    LIMIT è "solo" per db mySQL.

  6. #6
    Ok grazie,
    farò che consultare direttamente il manuale messso a disposizione da MySQL AB.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.