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!
Break! I didn’t plan it. One day I just didn’t feel like opening Instagram—and then…
AI tools Let’s be real—AI sounds like either a robot apocalypse or something only tech…
Summer vacation is a great time for kids to explore, have fun, and learn new…
Goal: Understand transformers, large language models, and the architecture behind ChatGPT. Tutorial Suggestions: ✅ “Transformers…
Goal: Build apps or tools with ChatGPT or GPT-4 API. Tutorial Suggestions: ✅ OpenAI API…
Goal: Learn how to prompt better, write content, brainstorm, code, etc. Tutorial Suggestions: ✅ OpenAI's…