Jump to content

Kedaeus_Sendre

New Members
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Kedaeus_Sendre's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I thought that as well.. However.. James Jones (ssn) is a 1 to many key.. So James jones has 3 kids.. and 1 wife.. When I run my query.. SELECT * from personnel_info LEFT JOIN dependant_info ON personal_info.ssn = dependant_info.sponsor_id LEFT JOIN spouse_info ON personal_info.ssn = spouse_info.sponsor_id WHERE personal_info.ssn = '555-55-5555' It pulls up the information I want and lists one row per child.. with redundant information except where the children information is different. It may be wrong - I couldn't tell you as I lack experience - but i'm getting the information I need. Maybe I shouldn't be pulling all the information at once.. Even still if I broke the dependants and the spouse off of that query and ran them in separate queries $query = "SELECT * from dependant_info where sponsor_id = $personnel_ssn"; $result = mysql_fetch_object($query); There would still be three rows of information that i'm supposed to be fetching.. I suppose my ultimate question is: are there three distinct objects created by doing so? Or.. How in the world do I access the other returned rows when fetching the information as an object? Or should I just use procedural code with a while loop and if statements?
  2. I've got a problem in a script i'm writing.. I don't understand how to easily pull information out of multiple returned rows. Up until now, I've been pulling information from my database with mysql_fetch_object($result) where $result is obviously the result of my query.. mainly because I can still work with the field names in my database - which is a lot easier than an array of indexes. My SQL Query LEFT JOIN's several tables.. we'll call them Personnel_info, Dependant_Info, and Spouse_Info If my query returned a visual table it would look like the following Personnel_Info Dependant_Info Spouse_Info pi_fname, pi_lname, pi_address di_fname, di_lname, di_sex si_fname, si_lname, si_anniversary James Jones 333 Street Mike Jones M Sarah Jones 2000-01-01 James Jones 333 Street Anne Douglass F Sarah Jones 2000-01-01 James Jones 333 Street David Jones M Sarah Jones 2000-01-01 I can access the first row of the returned result just fine, however I don't know - and have been unsuccessful at finding the answer on - how to access the other returned rows on a mysql_fetch_object statement.. So basically - I am unable to display the child dependants of James Jones (both Anne and David) (object class) or I get James Jones and Sarah Jones several times through procedural code.. I'm dealing with around 210 different columns in this one query through about 14 table joins and - as far as I see it using objects is the easiest way to pull the information and use it the way I see fit. It worked well for all the tables that are guaranteed to display only one row of information. :-\ Anything? -Kedaeus
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.