开发者

Check whether MySQL record exists based on 2 parameters

开发者 https://www.devze.com 2023-02-10 02:38 出处:网络
I\'m creating a PHP system that needs to check whether a record exists. I\'m fine checking whether a record exist that matches a sing开发者_JAVA技巧le column:

I'm creating a PHP system that needs to check whether a record exists.

I'm fine checking whether a record exist that matches a sing开发者_JAVA技巧le column:

mysql_query("SELECT * FROM articles WHERE s_id = '$myVar'")

However, I want to see whether there is an exact match for two columns in the database (a_id and s_id), while ignoring the match of the 3rd column.

Any ideas on how to check for a match on two parameters exist?


Thanks so much for taking a look - feel free to ask for any clarifications.


mysql_query("SELECT * FROM articles WHERE s_id = '$myVar' AND a_id= '$myVar2'")


Try:

mysql_query("SELECT * FROM articles WHERE s_id = '$myVar' AND a_id = '$myOtherVar'")
0

精彩评论

暂无评论...
验证码 换一张
取 消