If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Multiple Values in One Field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-26-04, 20:05
lpshow lpshow is offline
Registered User
 
Join Date: Jun 2004
Posts: 3
Multiple Values in One Field

Good day

I would like to know how to create a table, and query, that allows me to store multiple values in one field, and to link that field to another table.

For Example:
I have a database with 2 tables:
first table:
1) number_joined*
2) Surnames
3) FirstNames
4) month_Of_Birth

Second table:
1) Queries*
2) people

* indicates primary field
-----
ok say the first table had the following values:
1,"moo","cow","March"
2,"roar","dragon","May"
3,"oink","pig",March"

Now i want one query that returns only the records with "March" as the month_Of_Birth, and store the number_joined value of each return record ('1','3') into the field "people".
The another query that returns all the records from the first table, that have their primary key stored in the people field of the second table.

I am *very* new to SQL, so please excuse me for lack of lingo
Reply With Quote
  #2 (permalink)  
Old 06-27-04, 02:17
Mughrabi Mughrabi is offline
Registered User
 
Join Date: Feb 2004
Posts: 11
Exclamation

what do u mean by "of each return record ('1','3')" ?
Reply With Quote
  #3 (permalink)  
Old 06-27-04, 04:13
lpshow lpshow is offline
Registered User
 
Join Date: Jun 2004
Posts: 3
sorry, um the values in brackets are what it would return from my example
Reply With Quote
  #4 (permalink)  
Old 06-27-04, 05:02
Mughrabi Mughrabi is offline
Registered User
 
Join Date: Feb 2004
Posts: 11
am not quit sure I understand what u wanna do , but if u simply want to read
the records that match 'march' for month_Of_Birth

select number_joined from first_table where month_Of_Birth='march'

then according to ur prog. language , do a while to insert resultset in
second_table

is this close to what u wanna do?
Reply With Quote
  #5 (permalink)  
Old 06-27-04, 05:17
lpshow lpshow is offline
Registered User
 
Join Date: Jun 2004
Posts: 3
well, this is for a school project, and the requirements are that our database has 2 tables linked to each other. And the idea i have to link the table would require a field that contains multiple values.
Reply With Quote
  #6 (permalink)  
Old 06-27-04, 09:28
Mughrabi Mughrabi is offline
Registered User
 
Join Date: Feb 2004
Posts: 11
Unfortunately , there are no foriegn keys in Mysql in order for u to link the column number_joined in the first table with Queries in the second table,
but what u can do is to insure databse intergity manually through insert statments (whenever u insert a value in Queries , check that it exists in number_joined ) , and when u do a select , do it like this :

select f.Surnames , f.FirstNames , f.FirstNames , s.people from first_table f, second_table s where f.number_joined=s.Queries
Reply With Quote
  #7 (permalink)  
Old 06-29-04, 22:24
mmaru mmaru is offline
Registered User
 
Join Date: Jun 2004
Posts: 2
MySQL does support Forien Keys. Please follow the link and you can also get a good example in the manual for what you are trying to do.
http://dev.mysql.com/doc/mysql/en/In...nstraints.html

-MM
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On