0

How to retrieve the exact string matching rcord using mysql query.

This is mytable "course"

course_id course_name
36,45        C#
136,137       Data Entry 

When i retrieve a record in a course table the course_id hold "136" it retrive 36 also.

Please help me for retrieve exact string matching record.

4

1 回答 1

0

Use FIND_IN_SET

select * from your_table
where find_in_set(36, course_id) > 0

But actually you should really change your DB structure. Never store multiple values in one column!

Your table should look like this (who knows why you have multiple ids for the same course)

course_id   course_name
36          C#
45          C#
136         Data Entry 
137         Data Entry 
于 2013-09-25T07:39:00.560 回答