简体   繁体   English

根据2个参数检查MySQL记录是否存在

[英]Check whether MySQL record exists based on 2 parameters


I'm creating a PHP system that needs to check whether a record exists. 我正在创建一个PHP系统,该系统需要检查记录是否存在。

I'm fine checking whether a record exist that matches a single 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. 但是,我想看看数据库中的两列(a_id和s_id)是否存在完全匹配,而忽略了第三列的匹配。

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'")

尝试:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM