开发者

Check whether MySQL record exists based on 2 parameters

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜