Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2004
    Posts
    3

    Unanswered: 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

  2. #2
    Join Date
    Feb 2004
    Posts
    11

    Exclamation

    what do u mean by "of each return record ('1','3')" ?

  3. #3
    Join Date
    Jun 2004
    Posts
    3
    sorry, um the values in brackets are what it would return from my example

  4. #4
    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?

  5. #5
    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.

  6. #6
    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

  7. #7
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •