Jump to content

Zojak_Quaguz

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Everything posted by Zojak_Quaguz

  1. Well, the only number I am interested in is the total. The data just happens to come with subtotals for each month. So yes, I want to add a new field which is the sum of all the months.
  2. Hello, I have a table like this: Name,Jan,Feb,Mar John,1,5,2 Steve,2,9,3 Eric,4,4,1 I want to add a column to the table so it looks like this: Name,Jan,Feb,Mar,Total John,1,5,2,8 Steve,2,9,3,14 Eric,4,4,1,9 So that for each row, the 'Total' column is a sum over multiple columns (in this case, Jan, Feb, and Mar). I think I can generate the 'Total' column by SELECT Jan+Feb+Mar But how do I add it to the table?
  3. Yeah, come on now, I'm working with tables with BILLIONS of records!
  4. This one perplexes me. I can't find anything in the documentation about it, and I would be surprised if MySQL doesn't include functionality for such a simple task. LOAD DATA INFILE 'blah.txt' INTO TABLE blah FIELDS TERMINATE BY ' ' LINES TERMINATED BY '\n'; example file: 83726291 4 92923612 1 42093723 0 12321742 1 91283747 2 01249243 4 It keeps loading the entire line into a single field, so my table ends up with column 2 being NULL.
  5. I have a table with names of people and their job types, like so: Table 1 (People): [person1 varchar(25), person2 varchar(25), job1 varchar(50), job2 varchar(50)] And a second table with various combinations of job types: Table 2 (Jobs): [job1 varchar(50), job2 varchar(50)]; I want to remove all rows from the first table where BOTH jobs match a row from the second table. Example: Table 1: 1. John, Steve, Electrician, Plumber 2. John, Alex, Electrician, Carpenter 3. John, Sarah, Electrician, Installer 4. Steve, Alex, Plumber, Carpenter 5. Sarah, Alex, Installer, Carpenter 6. Sarah, Steve, Installer, Plumber Table 2: Electrician, Carpenter Installer, Carpenter Electrician, Installer So the query should remove rows 2, 3, and 5. I've tried a bunch of different things but it doesn't seem to work properly. The real tables are much larger (the jobs table has 5,000 or so combinations, so I can't do it manually). Any clues?
  6. MrAdam: Affected rows 0. PFMaBiSmAd: Weird. I did that, and the second row showed up as NULL just as before.
  7. I know, but that's what I was asked to do
  8. Yeah, topcat's code is what I used as the basis for mine. And thanks, laffin.
  9. Table "people" has two columns: ID_NUMBER varchar(5), NAME varchar(20). Sample rows: 1 John 2 Steve 3 Suzy 4 Janet Table "relationships" has two columns: PERSON1 varchar(20), PERSON2 varchar(20). Sample rows: 1 2 1 3 1 4 2 3 2 4 3 4 I want to replace the numbers in table "relationships" with the matching names from table "people". I tried UPDATE people p, relationships r SET r.PERSON1 = p.NAME WHERE r.PERSON1 = p.ID_NUMBER; which worked fine, then I tried to update the second column with UPDATE people p, relationships r SET r.PERSON2 = p.NAME WHERE r.PERSON2 = p.ID_NUMBER; and nothing happened. Thoughts?
  10. I have two arrays, X and Y, which contain names. The arrays are of the same size. The arrays are related to each other such that for each pair X[n] , Y[n] X is friends with Y. For example: X[0,1,2] = [Link, Cloud, Cloud, Mario, Mario, Luigi] Y[0,1,2] = [Zelda, Barrett, Tifa, Luigi, Bowser, Mario] Link is friends with Zelda Cloud is friends with Barrett and Tifa Mario is friends with Luigi and Bowser Luigi is friends with Mario I want to loop through these arrays and, for each unique name, find all of that person's friends. I then want to print the results to a text file, like so: Link, Zelda Cloud, Barrett, Tifa Mario, Luigi Luigi, Mario I know how to do this theoretically, but I just need help with the PHP syntax. Thanks very much.
×
×
  • 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.