php - 使用简单的类似查询获取数据问题

标签 php mysql

job_detail - table

apply - table

这是我的查询

SELECT DISTINCT *
 FROM job_detail, apply 
WHERE job_detail.job_id = apply.job_id 
AND apply.end_user_id =1 
AND job_detail.jobtitle =  'barber'
AND (job_detail.Zip LIKE  '%900%' 
OR job_detail.city LIKE  '%900%' 
OR job_detail.country LIKE '%900%')

它返回给我 id 37 的记录...但我获取的数据必须为空

最佳答案

使用显式连接语法并看看会得到什么

select a.*
From job_detail j
Join apply a
    On j.job_id = a.job_id 
    AND a.end_user_id =1 
    AND j.jobtitle =  'barber'
    AND (j.Zip LIKE  '%900%' 
    OR j.city LIKE  '%900%' 
    OR j.country LIKE '%900%')

关于php - 使用简单的类似查询获取数据问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30961788/

相关文章:

php - 从表中获取 2 列到 assoc 数组 php

php - Wordpress - 按字母顺序对包含数字和字母的帖子进行排序

php - 一些主机不喜欢设置名称 utf8 -- "Cannot execute queries while other unbuffered queries are active."

mysql - 如果 mysql 转储文件具有 blob 字段但在不使用 --hex-blob 参数的情况下转储,如何修复它?

php - 如何使用 htaccess 重定向多参数 url

php - 如何在mysql_query中添加变量

php - 将 Canvas 图像保存到 mysql

mysql - 打开与此连接关联的 DataReader,必须先关闭该连接

python - 邮政数据库。 models.py 没有转化为数据库方案

MySQL : FORCE INDEX vs USE INDEX