Here’s my query
SELECT * FROM wp_postmeta WHERE meta_value LIKE '".$_POST['username']."' AND meta_value LIKE '".$_POST['password']."'
The thing is that the meta_value username and the meta_value password are in 2 different rows. I need to make a query that will look for both and tell me if the vars that I look for are in those rows. So I would like the result to return 1 with a simple
mysql_num_rows();
I know this is silly and should be on the same rows with different columns but I need to work with that stupid wordpress plugins who’s doing it like it want.
You can use the
HAVINGclause in conjunction withGROUP BYto retrieve rows satisfying ALL conditions that happen across multiple rows rather than columns:Do not insert $_POST values into the query directly, that is an open call for SQL injection attacks. Because you are using the deprecated
mysql_*functions: at the bare minimum, run your $_POST variables throughmysql_real_escape_string(). But best to use PDO and its support for prepared statements.