1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| // Pour les bases de données (syntaxe sucrée pour l'API JDBC) :
ResultSet result := SELECT t1.id AS identifiant_client, t1.name AS nom_client, t2.*
FROM client t1
INNER JOIN information t2
ON t1.id = t2.fk_id_client
ORDER BY identifiant_client;
// On considère le mot-clé value équivalent à this, mais pour chaque occurrence
// Tout comme pour les EL dans JEE -> getId() devient id (on enlève le "get" et la parenthèse).
// Pour les listes :
List<String> listeClient = new ArrayList<String>(); // Remplir la liste
ResultSet result := SELECT value
FROM listeClient
WHERE value LIKE '%Pierre-%'
ORDER BY value DESC;
List<Client> listeClient = new LinkedList<Client>(); // Remplir la liste
ResultSet result := SELECT value.id, value.name
FROM listeClient
WHERE value.name LIKE '%Pierre-%'
ORDER BY value.id DESC;
//Equivalent (sans jointure) :
List<Client> listeClient = new LinkedList<Client>(); // Remplir la liste
ResultSet result := SELECT id, name
FROM listeClient
WHERE name LIKE '%Pierre-%'
ORDER BY id DESC;
// Avec jointure :
List<Client> listeClient = new LinkedList<Client>(); // Remplir la liste
List<Information> listeInformation = new LinkedList<Information>(); // Remplir la liste
ResultSet result := SELECT t1.id, t1.name, t2.*
FROM listeClient t1
LEFT JOIN listeInformation t2
ON t1.id = t2.fkClientId // Attention n'est pas une affectation, mais une comparaison !
WHERE t1.name LIKE '%Pierre-%'
ORDER BY t1.id DESC; |