If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
Is it possible to have several keywords in the search separated with an OR but only to show the records where there are ...let's say 4 of the 10 keywords available?
__________________
Compare bible texts (and other tools): TheWheelofGod
SELECT * FROM bible WHERE 1=1 AND text_data LIKE '%there%' OR text_data LIKE '%house%' OR text_data LIKE '%daughter%' OR text_data LIKE '%woman%' OR text_data LIKE '%conceived%' OR text_data LIKE '%goodly%' OR text_data LIKE '%child%' OR text_data LIKE '%three%' OR text_data LIKE '%months%' LIMIT 0, 10
The primary key is ID. The keywords are found in the text_area column.
__________________
Compare bible texts (and other tools): TheWheelofGod
SELECT *
FROM bible
WHERE 1=1
AND CASE WHEN text_data LIKE '%there%'
THEN 1 ELSE 0 END
+ CASE WHEN text_data LIKE '%house%'
THEN 1 ELSE 0 END
+ CASE WHEN text_data LIKE '%daughter%'
THEN 1 ELSE 0 END
> 1
this example shows how to test to see if at least 2 of the 3 conditions have been met
SELECT *
FROM bible
WHERE 1=1
AND CASE WHEN text_data LIKE '%there%'
THEN 1 ELSE 0 END
+ CASE WHEN text_data LIKE '%house%'
THEN 1 ELSE 0 END
+ CASE WHEN text_data LIKE '%daughter%'
THEN 1 ELSE 0 END
> 1
this example shows how to test to see if at least 2 of the 3 conditions have been met
how can I add another field outside of the CASES?
__________________
Compare bible texts (and other tools): TheWheelofGod
SELECT *
FROM (
SELECT bible.*
, CASE WHEN text_data LIKE '%there%'
THEN 1 ELSE 0 END
+ CASE WHEN text_data LIKE '%house%'
THEN 1 ELSE 0 END
+ CASE WHEN text_data LIKE '%daughter%'
THEN 1 ELSE 0 END
AS relevance
FROM bible
WHERE text_data LIKE '%there%'
OR text_data LIKE '%house%'
OR text_data LIKE '%daughter%'
) AS d
WHERE relevance > 4
ORDER
BY relevance
Where am I going to fit "AND book_spoke = ' ' OR chapter_spoke=' ' OR verse_spoke = ' '"
__________________
Compare bible texts (and other tools): TheWheelofGod
SELECT *
FROM (
SELECT bible.*
, CASE WHEN text_data LIKE '%there%'
THEN 1 ELSE 0 END
+ CASE WHEN text_data LIKE '%house%'
THEN 1 ELSE 0 END
+ CASE WHEN text_data LIKE '%daughter%'
THEN 1 ELSE 0 END
AS relevance
FROM bible
WHERE (
text_data LIKE '%there%'
OR text_data LIKE '%house%'
OR text_data LIKE '%daughter%'
)
AND (
book_spoke = ' '
OR chapter_spoke = ' '
OR verse_spoke = ' '
)
) AS d
WHERE relevance > 4
ORDER
BY relevance