1

I have a mysql table as below:

--------------------
| Sl | col1 | col2 |   
--------------------
| 1  | data1| msg1 | 
--------------------
| 2  | data2| msg2 | 
--------------------
| 3  | data1| msg3 | 
--------------------
| 4  | data2| msg4 | 
--------------------
| 5  | data1| msg5 | 
--------------------

I have a php string $query = "select * from table WHERE col1='data1'"; , which fetch array 3 results (row number 1, 3, and 5). But i want to get a specific row containing "data1" in "col1" and "msg3" in "col2" (which is row number 3) in a single query. How can I make this possible?

1 Answer 1

6

Use AND in the WHERE clause to match multiple conditions:

SELECT * FROM table WHERE col1='data1' AND col2='msg3'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.