Visualizzazione dei risultati da 1 a 6 su 6

Discussione: Query 2 tabelle

  1. #1

    Query 2 tabelle

    Cosa ha che non va questa query doppia? mi da argomento non valido

    Codice PHP:
    $h "SELECT *,DATE_FORMAT(acquisti_ris1_yes.Data, '%H:%i %d/%m') as acquisti_ris1_yes.Data_n, 
    DATE_FORMAT(acquisti_ris2_yes.Data, '%H:%i %d/%m') as acquisti_ris2_yes.Data_n FROM acquisti_ris1_yes, acquisti_ris2_yes ORDER BY acquisti_ris1_yes.Data, acquisti_ris2_yes.Data DESC Limit 0,06"
    ;
    $hh mysql_query($h$db); 
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  2. #2
    Utente di HTML.it L'avatar di Gab-81
    Registrato dal
    Nov 2005
    Messaggi
    558
    Prova a fare

    Codice PHP:
    $hh mysql_query($h$db) or die(mysql_error()); 
    e vedi di preciso l'errore che ti da. Argomento non valido potrebbe essere anche il nome di una colonna scritto male...
    Buon anno

  3. #3
    codice:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.Data_n,DATE_FORMAT(acquisti_ris2_yes.Data, '%H:%i %d/%m') as acquisti_ris2_yes.' at line 1
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  4. #4
    Utente di HTML.it L'avatar di Gab-81
    Registrato dal
    Nov 2005
    Messaggi
    558
    Probabilmente ti da errore perchè la clausola AS rinomina un solo valore alla volta, mentre tu dai una SELECT *. Prova a fare

    SELECT acquisti_ris1_yes.Data,DATE_FORMAT(acquisti_ris1_y es.Data, '%H:%i %d/%m') as acquisti_ris1_yes.Data_n, acquisti_ris2_yes.Data,DATE_FORMAT(acquisti_ris2_y es.Data, '%H:%i %d/%m') as acquisti_ris2_yes.Data_n FROM acquisti_ris1_yes, acquisti_ris2_yes ORDER BY acquisti_ris1_yes.Data, acquisti_ris2_yes.Data DESC Limit 0,06";

    Così prendi solamente acquisti_ris1_yes.Data e acquisti_ris2_yes.Data e le rinomini con la clausola AS...dovrebbe andare bene così. Non ho praticamente mai usato DATE_FORMAT, quindi non so come si usa e dove si posiziona all'interno della query...

  5. #5
    as acquisti_ris1_yes.Data_n

    non puoi dichiarare il database nell'alias. Solo il campo. Il risultato sara' in una unica nuova tabella (trasparente) che porta il result set.

    Poi per il raggruppamento deve esserci un group by altrimenti altro errore, inoltre dovresti indicare il campo che unisce in JOIN le due tabelle. In altre parole query da rivedere in toto.

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  6. #6
    Utente di HTML.it L'avatar di luca200
    Registrato dal
    Apr 2002
    Messaggi
    4,120
    Non vuole il punto nella AS

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 © 2025 vBulletin Solutions, Inc. All rights reserved.