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:
- Match rows with all the attributes
- 2 Matching rows with attributes
- 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
Post a Comment