2 Replies - 2123 Views - Last Post: 09 May 2013 - 06:17 PM

#1 DespicableMe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 07-May 13

How to match a single column id with a multiple id in a single column

Posted 07 May 2013 - 10:26 PM

Dear folks,i have two tables namely test and questionentry. questionentry table is having qId(int), questionName and subject field(Column) and on the other hand, test table contains testId, duration, questionIds(Var char) and publish etc. In testId, i have multiple values of qId stored in it in format eg 22,23,24,25,28. I am having a problem about how to select only the particular rows in which questionentry.qId exist in test.questionIds. Since i am using questionName in varchar format so it's difficult for me to compare it. Any idea about how to solve it?

Is This A Good Question/Topic? 0
  • +

Replies To: How to match a single column id with a multiple id in a single column

#2 DespicableMe  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 07-May 13

Re: How to match a single column id with a multiple id in a single column

Posted 08 May 2013 - 06:29 AM

I think that i have to change my database design again. maybe i will have to do many to many relationship by making an extra table quetionTest and i that table all i have is to insert testId and questionid that's it but it will takes more time as i have to do loop also for inserting multiple questions for a single test.
Was This Post Helpful? 0
  • +
  • -

#3 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 879
  • View blog
  • Posts: 1,893
  • Joined: 30-January 09

Re: How to match a single column id with a multiple id in a single column

Posted 09 May 2013 - 06:17 PM

That first design you're showing goes against normalisation to the point that it does not even meet 1NF (first normal form). Atli has written an excellent tutorial on DB normalisation, which you can access here.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1