2013-08-07 3 views
0

안녕하세요 저는 다음과 같은 쿼리를 가지고 있지만, 아직 나에게주지 않는 결과를줍니다. 이게 뭐가 잘못 됐니?mysql이 성명서에서 작동하지 않습니다.

select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id from hierarchy left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn where taxonomic_units.rank_id = 220 and hierarchy.hierarchy_string LIKE '%180211%' and taxonomic_units.tsn not in ('180212') order by rand() limit 1 

select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id from hierarchy left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn where taxonomic_units.rank_id = 220 and hierarchy.hierarchy_string LIKE '%180210%' and taxonomic_units.tsn not in ('180212,573165') order by rand() limit 1 

select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id from hierarchy left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn where taxonomic_units.rank_id = 220 and hierarchy.hierarchy_string LIKE '%180130%' and taxonomic_units.tsn not in ('180212,573165,573165') order by rand() limit 1 

select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id from hierarchy left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn where taxonomic_units.rank_id = 220 and hierarchy.hierarchy_string LIKE '%179913%' and taxonomic_units.tsn not in ('180212,573165,573165,585192') order by rand() limit 1 

select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id from hierarchy left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn where taxonomic_units.rank_id = 220 and hierarchy.hierarchy_string LIKE '%158852%' and taxonomic_units.tsn not in ('180212,573165,573165,585192,624896') order by rand() limit 1 

여기에 중복으로 결과입니다, 내는 성명에서 사람들을 걸러 생각하지만 나던 아니었다.

0 180212 
1 573165 
2 573165 
3 632899 
4 632141 
5 647171 

답변

0

사용이 쿼리 :

select taxonomic_units.tsn, hierarchy.hierarchy_string, hierarchy.TSN, taxonomic_units.rank_id 
    from hierarchy 
     left join taxonomic_units on hierarchy.TSN = taxonomic_units.tsn 
     where taxonomic_units.rank_id = 220 
      and hierarchy.hierarchy_string LIKE '%158852%' 
      and taxonomic_units.tsn not in ('180212','573165','573165','585192','624896') 
     order by rand() limit 1 

는 이러한 다른 값이기 때문에 모든 값에 '를 추가해야합니다. 그리고 시작과 마지막에 단일 문자열로 처리했습니다.

+0

그는 분명히 다음 번호를 알지 못합니다. –

+0

@ YourCommonSense 그러나 출력 결과에 따르면 이러한 유형이어야하므로 잘못된 것은 아닙니다. downvote 필요 없음. –

+0

어떻게 PHP에서이 작업을 수행 할 수 있습니까? 이거? " ''. implode (" ','", $ myArray). " '"; – user2604754

관련 문제