GROUP_CONCAT是我的流派

时间:2016-09-25 04:39:45

标签: mysql

如何不用searh修剪grop_concat结果?

set i 0
IP_FILE="./hst.txt"

for i in `cat $IP_FILE`; do
sapwn ssh "@$i"
expect {
"*\#"  { send "cd /var-tmp"; send "./scmd.sh -tmp /var/tmp -plugins /var/tmp/plugins -dmore \r";  }
 "*\#" { puts "ejecucion exitosa" }
}
EOD
done>>logfile.txt`

工作正常

idbook
book_id | genre_id
idgenre | genre

结果

SELECT 
    GROUP_CONCAT(genre) AS thisgenre,
FROM
    book
        LEFT JOIN
    genre_book ON idbook = book_id
        LEFT JOIN
    genre ON genre_id = idgenre
GROUP BY idbook

当我尝试搜索(horror horror,drama,mistic horror,mistic,psihology )时:

WHERE genre_id = 1

结果:

SELECT 
    GROUP_CONCAT(genre) AS thisgenre,
FROM
    book
        LEFT JOIN
    genre_book ON idbook = book_id
        LEFT JOIN
    genre ON genre_id = idgenre
WHERE genre_id = 1
GROUP BY idbook

如何使用WHERE(或其他搜索)获得第一个结果?

0 个答案:

没有答案