I have a search keyword and I am searching for that keyword using two tables.
The search keyword is 'Patient'
Table - default_pages
id type_id parent_id status
68 16 0 draft
70 17 68 live
227 17 44 live
262 1 31 live
Table - default_search
id title entry_id
1 patient status 70
2 patient check 227
3 patient health 262
My query is
"SELECT
s.title, p.id, p.type_id AS sqem
FROM default_search s LEFT JOIN default_pages p ON p.id=s.entry_id
WHERE s.title LIKE '%Patient%'
HAVING sqem IS NOT NULL"
The above query returns 3 results where the ids from default pages are 70, 227, 262 but the problem is for the id 70, it's parent id is 68 and the status of id 68 is draft so I want to exclude this row from the result set and this is where I am stuck.
Any help is highly appreciated. Thanks in advance.