On 9/23/06, u k <[EMAIL PROTECTED]> wrote: > 1) Names > ---------- > id int(10) > name varchar(50) > > dummy datas > ------------------- > 1, 'John' > 2, 'Roy' > 3, 'Mary' > > 2) Class > ------------ > id int(10) > names varchar(100) > > dummy datas are > ----------------------- > 5, 'Lin, John' > 6, 'Kiran, Lisa , Prem' > > My problem is .... I want to get the records in which name in table 'Names' > should be names in table 'Class' > for ex. i want to get all the record from Class which contains the name > 'John' (bcoz john is there in table 'Names')
Well, although you can solve this problem using LIKE, you really should pay attention to table normalization, because this could get you all kinds of trouble in the future. What if you had two people with the same name? If you have a table for people and another for classes, and assuming people can be in multiple classes AND a class can have multiple people, you should create a third table to link one to another by their IDs. Something like this: Table name_class: id_name int not null, id_class int not null This way you would be inserting several lines on this table, and each row would say that person X is in class Y. You could fetch everything in just one row using a simple JOIN. Try to avoid linking things by name instead of ID, and to put several values in a single field, as this breaks normalization. -- Bruno Lustosa <[EMAIL PROTECTED]> ZCE - Zend Certified Engineer - PHP! http://www.lustosa.net/ Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/php-list/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
