MySQL Join Comma Separated Field -


i have 2 tables. first table batch table contain comma separated student id in field "batch"

batch -------------- id      batch  -------------- 1       1,2      2       3,4 

second table marks

marks ---------------------- id  studentid   subject     marks 1     1         english     50 2     2         english     40 3     3         english     70 4     1         math        65 5     4         english     66 6     5         english     75 7     2         math        55 

how can find students of first batch id =1 have scored more 45 marks in english without using sub query.

problem found done using single query can not use in association operator in join statement

what changes required in below query make work?

select * batch inner join marks on marks.studentid in(batch.batch) batch.id = 1 

select  m.studentid    batch b join    marks m on      find_in_set(m.studentid, b.batch)         , m.subject = 'english' group         m.studentid having  sum(marks) > 45 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -