2012-02-22 29 views
-1

我有一个表:如何筛选基于2个字段的查询

user_qualifications: 
    id 
    user_id 
    type 
    title 
    description 

我需要得到基于2个过滤器的所有字段...喜欢的工作经验和教育。这些将是类型。我需要做2个查询吗?我需要展示他所有的工作经历和所有的教育,可能是多行排序foreach类型。

+0

你能给出'user_qualifactions'的一些示例数据以及你想要的示例输出? – MatBailie 2012-02-22 11:19:58

+0

即使是作业,这也是一个太简单的问题。 – 2012-02-22 11:42:43

+0

@SzilardBarany - 除*** ***出现在EAV表格外,且没有AvidProgrammer答案中引用的字段“work_exp”和“education”。而任何认为将这些查询用于EAV的“微不足道”的人早已忘记了第一次处理它们时的情况。 – MatBailie 2012-02-22 12:06:04

回答

3

使用

select id, user_id, type, title, description 
from user_qualifications 
where Work_exp = 2 and education="MS" 
+0

当我没有ms,只有工作exp然后它会打破 – Mythriel 2012-02-22 11:15:53

+0

而你在where子句中使用的两个字段根本不存在于OP的模式中。 – MatBailie 2012-02-22 12:08:39

0

没有回答我的问题的意见,我只能让一个受过教育的猜测,你真正需要的。

我想你想的东西像...

SELECT 
    * 
FROM 
    user_qualifications 
WHERE 
    type IN ('work experience', 'education') 
0

员额由AvidProgrammer应该不包括双引号,而不是使用单引号,否则你会得到一个编译错误

SELECT id, user_id, type, title, description 
FROM user_qualifications 
WHERE experience = 2 and education = 'BSC' 
相关问题