Ecco come ho usato la funzione e la query per intero:
SELCT tables.id FROM tables, customers
WHERE tables.nseats >= '$Customer->nseats' AND tables.id = customers.idtable AND customers.date <= DATA_ADD('$Customer->date',INTERVAL 2 HOUR)
ORDER BY customers.date DESC
LIMIT 1
La prima clausola WHERE è per controllare se il numero di sedie del tavolo è abbastanza per il numero di sedie che servono al cliente, la seconda per vedere se il tavolo è prenotato (JOIN tra diverse tabelle), la terza per vedere a che ora il tavolo è prenotato.
Ecco l'errore che ho quando eseguo:
Query error: 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 ') ORDER BY customers.date DESC LIMIT 1' at line 1