i tried lots of thing but not of them worked hope someone may help me with this query
let me show my query first then issue
select log.*,client.client_name
from ( select * from sessions
where ( `report_error_status` like CONCAT('%' ,'consec', '%')
or `ipaddress` like CONCAT('%' ,'consec', '%') or `last_updated` like CONCAT('%' ,'consec', '%') )
ORDER BY `id` DESC LIMIT 10 OFFSET 0 )
log
inner join
(select * from clients
where ( `client_name` like CONCAT('%' ,'consec', '%') ) )
client on log.client_id = client.id
in order to prevent exponential reducing query speed i'm applying limit in my table session above query working perfectly fine without "where", but my problem lies over here if user from front end try to search any thing in datatable , where clause is dynamically get attached in backend (above query with where) now my problem is that suppose table (session) does not contain user search value consec ,but table (client) contain then final query still return null value now is there any way to apply conditional where like below query
ifnull((select id from sessions where
(`report_error_status` like CONCAT('%' ,'consec', '%')
or `ipaddress` like CONCAT('%' ,'consec', '%')
or `last_updated` like CONCAT('%' ,'consec', '%'))
),
(select * from sessions ORDER BY `id` DESC LIMIT 10 OFFSET 0) ))
it will resolve all my problem is there any way to achieve in mysql. if table session contain 100 000 data it will search with client table one by one against 100k records. suppose time taken to execute is 1 sec now what if my session table has 200k data again time will increase exponentially in inner join, to avoid this i'm using subquery in session with limit
Note report_error_status,ipaddress, client_name etc in index