SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    plus search and the record which has the same order with keyWord

    Code:
    data in myTable
    (ID)  message  
    (1) I am a boy 
    (2) You are a girl
    (3) He is ambitious 
    (4) They are happy 
    (5) Who are you
    I have the above data in myTable, and I have the following ColdFusion code and SQL code for plus search.

    Code:
    CFML and SQL code
    <cfset keyWord1 = trim(ListFirst(keyWord, '+'))>
    <cfset keyWord2 = trim(Listlast(KeyWord, '+'))>
    
    <cfquery datasource="DS" name="test1">
    	select ID, message
    	from myTable6
    	where message like '%#keyWord1#%' and message like '%#keyWord2#%'
    </cfquery>
    
    <cfoutput query="test1">
    	(#ID#) #message#<br>
    </cfoutput>
    If keyWord is "are+you" with the above code, it will produce the following resutl.
    Code:
    result for keyWord "are+you"
    (2) You are a girl 
    (5) Who are you
    I like to produce the following target result with the keyWord "are+you,
    Code:
    target result
    (5)Who are you
    Please notice "Who are you" is in same order with the keyWord "are+you", While "You are a girl" NOT.


    Thanks in Advance

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    joon, you are getting so complicated, you can't see the simple solutions any more!!

    where message like '%#keyWord1#%#keyWord2#%'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •