0

Have two table in mysql database with table1 and table2,

 table1
         id      marks      hodname
         1       10%         abc
         2       20%         tec
         3       50%         med
         4       60%         abc
         5       70%         tec
 table2
         uid            hodname
         1                abc
         2                tec
         3                med

I want to fetch hodname with marks but condition is if any hod have marks below 30% should not be in result. Only hod with above 30% i want in result if he is having alteast on marks below 30% then don't consider in result.Please help me out with mysql query for this.
Result should be

 table2
         marks            hodname
         50%                med
4

1 回答 1

1
select table1.marks, table2.hodname
from table2 
inner join table1 on table1.id = table2.uid
where marks > 30

or if your marks is a string with percentage symbol:

select table1.marks, table2.hodname
from table2 
inner join table1 on table1.id = table2.uid
where replace(marks,'%','')*1 > 30
于 2012-08-30T06:08:22.453 回答