From 1a33b8596317923dc17fcd19e37a58076c71c781 Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 13 Nov 2013 19:25:43 +0100 Subject: [PATCH] [trouver] On peut chercher les numcbde en LIKE --- bde/trouver.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bde/trouver.sh b/bde/trouver.sh index d25f29a..47dca06 100755 --- a/bde/trouver.sh +++ b/bde/trouver.sh @@ -6,14 +6,22 @@ for i in $@ do if [ $i = "--no-mail" ] then nomail=1; + fi; + if [ $i = "--numcbde" ] + then searchnumcbde=1; fi done -# Si on n'a *pas* mis no-mail (too many negations, I know) -if [ -z "$nomail" ] +# Si on n'a *pas* mis --no-mail (too many negations, I know) +if [ -z "${nomail}" ] then adding=" OR email ILIKE '%$1%'" fi +# Si on a mis --numcbde, il faut matcher numcbde de manière plus lâche +if [ "${searchnumcbde}" = "1" ] +then + wild="%" +fi psql bde -c "SELECT * FROM adherents WHERE pseudo ILIKE '%$1%' OR nom ILIKE '%$1%' - OR prenom ILIKE '%$1%'$adding OR CAST(numcbde AS varchar)='$1' ORDER BY nom;" + OR prenom ILIKE '%$1%'${adding} OR CAST(numcbde AS varchar) LIKE '${wild}$1${wild}' ORDER BY nom;" -- 2.39.2