I'm trying to understand how the following statement will execute on multiple records.
SELECT * FROM test
WHERE product='$product'
AND (summary LIKE '%$keywords%' OR exp LIKE '%$keywords%')
ORDER BY `$order_by` DESC;
I'm fairly new to SQL so here's what I'd like to know:
1. When you execute a SQL query, I believe it looks at each row in the table. When a match is found, where does it temporarily store the result until all results can be returned?
2. In the above example, say we're looking at single row in the table and there is a match for summary
. Will the query continue to execute OR exp LIKE '%$keywords%'
when its already found a match?
It's up to the database engine to decide how to store the temporary result. Each database engine implementation might be different. What the client get is a result set consisting of rows (if the query produces result at all)
No, if the first condition in the OR evaluates to true, it will not check the second condition (what's the point of doing that anyway, you know the end result already)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With