From: Vincent Date: Wed, 13 Nov 2013 18:25:43 +0000 (+0100) Subject: [trouver] On peut chercher les numcbde en LIKE X-Git-Url: http://gitweb.pimeys.fr/?a=commitdiff_plain;h=1a33b8596317923dc17fcd19e37a58076c71c781;p=scripts-20-100.git [trouver] On peut chercher les numcbde en LIKE --- 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;"