2011-05-02 4 views
0

사용자가 특정 전투기의 성을 입력하여 결과를받을 수 있지만 전투기의 이름을 입력 할 수있는 쿼리를 변경하려고합니다. 이 작업을 수행하려면 아래 쿼리를 어떻게 변경해야합니까? 여기 SQL에서 WHERE 문을 수정하려면 어떻게합니까?

코드입니다 :

SELECT distinct 
'${searchT}' searchalp, 
(SELECT COUNT(fighterId) FROM tblFighter where fighter_lastName like '${searchT}%') totalresults, 
A.FighterID, 
A.Fighter_FirstName, 
A.Fighter_NickName, 
if (A.Fighter_Height > 0, 
CONCAT(FLOOR(A.Fighter_Height/12), '\' ', MOD(A.Fighter_Height,12), '"'), '')  Fighter_Height_inch, 
A.Fighter_NormalWeight, 
if (A.Fighter_Reach > 0, CONCAT(ROUND(A.Fighter_Reach,0), '"') , '') Fighter_Reach, 
A.Fighter_Stance, 
CONCAT('/fighter/',REPLACE(REPLACE(LCASE(A.Fighter_FirstName),' ','-'),'.',''),'/',REPLACE(LCASE(A.Fighter_LastName),' ','-'),'/',A.FighterID,'/') fighterURL, 
(select count(*) from tblFight_Fighter where FighterID = A.FighterID and OutcomeID = 1) fighterCareerWins, (select count(*) from tblFight_Fighter where FighterID = A.FighterID and OutcomeID = 2) fighterCareerLosses, (select count(*) from tblFight_Fighter where FighterID = A.FighterID and OutcomeID = 3) fighterCareerDraws, 
fighter_lastName, FA.AccoladeDescription FROM tblFighter as A LEFT JOIN (SELECT FighterId, AccoladeDescription, AccoladeType 
    FROM tblAccolade 
    JOIN tblEvent USING(EventID) 
    JOIN (SELECT AccoladeID, Max(Event_Date) as MaxAccDate 
      FROM tblAccolade 
      JOIN tblEvent ON tblAccolade.EventID = tblEvent.EventID 
     WHERE AccoladeType = 'Belt' AND AccoladeDescription not like 'WEC%' 
     GROUP BY AccoladeID) as tmpMaxAccDate ON tblAccolade.AccoladeID = tmpMaxAccDate.AccoladeID 


WHERE Event_Date = MaxAccDate) as FA ON FA.FighterId = A.FighterId and FA.AccoladeType = 'Belt' where A.fighter_lastName like '${searchT}%' order by A.fighter_lastName ASC LIMIT ${stInd}, ${lstInd} 
+0

'impute' - 무언가 정직하지 못한 행위 (특히 형사 범죄)에 대한 진술. '입력 '을 의미 했습니까? – mellamokb

답변

1

뭔가 where A.fighter_lastName like '${searchT}%' and A.fighter_firstName like '${searchU}%'처럼 그것을 할해야한다. 문자열 중 하나 또는 다른 문자열이 비어 있으면 검색은 전적으로 다른 문자열을 기반으로합니다.

+0

그게 작동하지 않았다. 을 사용해 보았습니다. 여기서 A.fighter_lastName은 '$ {searchT} %'또는 '$ {searchU} %'와 같은 A.fighter_firstName입니다. 그 중 하나가 작동하지 않았습니다. –

+0

사용자가 단일 문자열을 입력하도록하려는 경우. James와 Burt Jameson과 James Burtfield (잘 알려진 선수들!)가 돌아 오게하고 나서 당신이 가지고있는 것처럼 그것을 OR로 바꾸고 searchT를 searchT로 바꾸십시오 - 그래서 동일한 매개 변수가 두 곳에서 사용됩니다. –

+0

그 덕분에. –

관련 문제