Skip to content
Advertisement

MySQL SELECT only rows where tbl_col equal to this and that

I am struggling a bit with my SQL query.

This is the query i have now, and it works as is, but i want to add some more to it.

In the mysql table, there is a column that is named “type”. I want to filter the rows and get the rows with the string “sms” or the string “email” from column “type”.

$query = "
 SELECT id_card
     , date_sent
     , status
     , recipient
     , type 
  FROM dc_log 
 WHERE secretcode=?
   AND date_sent BETWEEN ? AND ?
";

How do i add this to my query without messing everything up?

Thanks in advance.

Advertisement

Answer

Just add this condition in the end before the double quotes

 AND type IN ('sms','email')

Resource

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement