Hi! I am creating a website where multiple persons can work on the same story. I have this table: id | authors 1 jim,steward 2 jim 3 george,steward etc. It's a list of stories and who worked on it. Say I want to know what stories Jim worked on. I know the IN()-function. You can search like: ...where authors IN('jim'). But I want a "reverse-function". So the field name is inside the brackets. Something like ....where 'jim' IN(authors). This doesn't work, but is there anything like that?
change your db design.. make a table authors make a table stories make a table author_stories that has 2 columns, authorid and storyid which is the link between both tables that way you can easily search who worked on what story, or on what stories an author worked
good solution flippers, thats probably the best way to do it but if your data is in a list "joe, bob, jim" and you don't want to change your tables you can always use wild cards where authors like '%jim%'
The first posted solution is the right one. As for using wildcards %% I wouldn't use it because '%jim%' does also match 'jimmy' so you would not get accurate results