SQL astuces

13 articles

Comment interroger les libellés des valeurs autorisées plutôt que les codes dans une requête ?

SELECT champ_de recherche FROM table WHERE champ_de_recherche=<<libelle_champ|valeur_autorisee>> Exemple : RECHERCHE GUIDEE PAR TYPE DE DOCUMENT SELECT biblio.title AS Titre, biblio.author AS Auteur, biblioitems.publicationyear AS Date, items.barcode AS Code_barres, items.itemcallnumber AS Cote FROM items,biblio,biblioitems WHERE items.itype=<<TYPE : |ITYPE>> AND items.biblionumber = […]

Comment extraire les attributs lecteurs?

SELECT borrowers.borrowernumber, borrowers.surname, borrowers.firstname, borrowers.cardnumber, borrower_attributes.code, borrower_attributes.attribute FROM borrowers LEFT JOIN borrower_attributes ON (borrowers.borrowernumber=borrower_attributes.borrowernumber) LEFT JOIN borrower_attribute_types ON (borrower_attribute_types.code=borrower_attributes.code) GROUP BY borrower_attributes.attribute ORDER BY borrowers.surname, borrowers.firstname ASC Résultat :