How can I fetch "partial matches" with mysql? -


I need to find the best match from a mysql table given a set of properties.

For example, ATTRIBUTE1, ATTRIBUTE2 and ATTRIBUTE3, I want to get results as follows:

  1. Match rows with all the attributes
  2. 2 Matching rows with attributes
  3. Matching rows made with 1 attribute

    Yet I only know how to complete the first description: < Choose> User> ATTRIBUTE1 = "aValue", ATTRIBUTE2 = "now", ATTRIBUTE3 = "now" LIMIT 20

    NB I need 2 lists A list with completely matching rows and partial matches

    If you have an overall index ATTRIBUTE {1..3}

    This will benefit users from List A

      SELECT *, where ATTRIBUTE1 = "aValue" and ATTRIBUTE2 = "AWWE" and ATTRIBUTE3 = "aValue" LIMIT 20   

    and List B

      SELECT * in some rows Can help, as IF (ATTRIBUTE1 = "aValue", 1, 0) A1, if (ATTRIBUT2 = "AWW", 1, 0) A2, IF (A) TTRIBUTE3 = "AVWU", 1, 0 users from A3 where ATTRIBUTE1 = "Awwu" or ATRIBUT2 = "Awwu" or ATRIBUT3 = "Awwu" Order By (A1 + A2 + A3) DESC LIMIT 20 < / Code>   

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -