| 1 | #!/bin/sh |
| 2 | |
| 3 | field=$1 |
| 4 | nom=$2 |
| 5 | promo=$3 |
| 6 | |
| 7 | query="SELECT $field FROM auth_user_md5 AS u " |
| 8 | where="" |
| 9 | pos=0 |
| 10 | for i in $nom ; do |
| 11 | query="$query INNER JOIN search_name AS sn${pos} ON (u.user_id = sn${pos}.uid) " |
| 12 | [ "$where" != "" ] && where="$where AND" |
| 13 | where="${where} sn${pos}.token LIKE \"${i}%\"" |
| 14 | pos=$((pos + 1)) |
| 15 | done |
| 16 | if [ "${promo}" != "" ] ; then |
| 17 | [ "$where" != "" ] && where="$where AND " |
| 18 | where="${where} u.promo = $promo" |
| 19 | fi |
| 20 | query="${query} WHERE ${where} GROUP BY u.user_id" |
| 21 | |
| 22 | echo $query | mysql --default-character-set=utf8 -N x4dat |