php - 如何对我的代码进行一次查询

标签 php mysql codeigniter

如何对我的代码进行一次查询

$sql = "SELECT id FROM countries WHERE country_code = LEFT($number,3)"; 
$sql = "SELECT id FROM countries WHERE country_code = LEFT($number,2)"; 
$sql = "SELECT id FROM countries WHERE country_code = LEFT($number,1)"; 
$sql = "SELECT id FROM countries WHERE country_code = 0";

最佳答案

$sql = "SELECT id
FROM countries
WHERE country_code = LEFT($number,3)
  OR country_code = LEFT($number,2)
  OR country_code = LEFT($number,1)
  OR country_code = 0"; 

关于php - 如何对我的代码进行一次查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43316027/

相关文章:

php - 使用ajax jquery运行php脚本

PHP用按钮插入MySQL

php - Walker 类的 Wordpress 问题

python - 如何在 MySQL 数据库中使用 UUID 而不是整数

java - 在 mySQL 上运行多个并发语句

php - 为什么数据库结果不显示重音?

php - MySQL 是否有针对基于 URL 的攻击的内置注入(inject)攻击保护?

php - 如何处理包含 500 多个项目的 Symfony 表单集合

c# - 在 MySQL 和 Entity Framework 6 的 Where 中使用 TimeSpan 时的错误结果

php - 如何覆盖 Codeigniter 3 路由以仅显示名称而不是 id 和名称