Hello, welcome to this short post or an answer for this question.
Here is example do use AND with WHERE clause in MYSQL statement in PHP or general writing of SQL Statement.
SELECT *
FROM orders
WHERE (userId = 111 AND orderId = 185)
This how we can use AND in where clause., similarly if we need OR in WHERE clause, we can use as below:
SELECT *
FROM orders
WHERE (userId = 111 AND orderId = 185)
OR (userId > 100);
Just if we are looking for complex query with multiple OR and AND in OR
SELECT orderId, orderNumber, orderStatus
FROM orders
WHERE (orderId = 185)
OR (orderNumber = 101 AND orderStatus = 'Cancelled')
OR (orderNumber = 102 AND orderStatus = 'InProgress' AND total >=500);
Purpose of this post to give you just syntax you might be looking for, but you know the logic how to implement it and use it!
Thanks for visiting and happy learning!
In today’s fast-paced work environment, meetings are essential but can often feel unproductive. However, by…
Gold is one of the most coveted precious metals in the world, adored for its…
Gold, the shimmering metal synonymous with wealth, power, and beauty, has been deeply intertwined with…
How to Onboard an Intern in a Small, Individual-Based Company Hiring an intern can be…