Jump to content

mrscoop

Members
  • Posts

    10
  • Joined

  • Last visited

mrscoop's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Could not edit in time to add this, sorry for the disjointed post. Matching TOES will have the same value in TACS. Sorry if I did not word that properly...I am a beginner ( but you probably already knew that).
  2. So's y'all know, this chart: TICS TACS TOE 6 9 a 12 0 c 10 0 d 4 9 a is actual, literal values in my db. TOE is an encrypted id that is about 80 characters long. I want to sum db column TICS where column TACS equals 0 (12 + 10) I want to sum unique values of TACS / or group by TOE (9) I want to add the 2 numbers together. (equals 31) Because I am a beginner, I do not know the best approach. If anyone can help (and play nice) I would be grateful.
  3. In my original question I assumed that there would be a single query and I would work with the array. Because I am a beginner! When I followed requnix's advice I did not get the desired results. So I posted new data. If my question irritates you you do not need to respond. It is not helpful!
  4. Thanks Psycho, Now you further see why I need help! How do I accomplish the goal?
  5. Thanks for the information, it has definitely headed me in the right direction: I expected the sum of TACS to be 9 as the query is grouped by TOE But the sum is 18 $query = $this->_db->getQuery ( true ); $query->select( 'sum(if(tacs=0, tics, tacs))'); $query->from ( 'table '); $query->group('toe'); $this->_db->setQuery ( $query ); $testsums = $this->_db->loadRowList(); returns this array: array {10,18,12) Here is a new table with my actual values TICS TACS TOE 6 9 a 12 0 c 10 0 d 4 9 a Expected results: 9 (grouped tacs) 10 + 12 (tics where tacs is zero) I appreciate your help. I am inspired to really learn instead of just getting by!
  6. Sorry, too late to edit so here is a revision TICS TACS TOE 5 0 a 3 5 c 1 0 d 9 3 c should come to 14: (5 + 1) + (5+ 3)=14
  7. Hi requinix, Yes, I am querying a MySQL database. And, yes, I posted bad example data. The TIC and TAC columns will not necessarily be the same values when TACS is zero. Thanks for having a look!
  8. Hello, Am working on a custom joomla component.... I want to sum db column TICS where column TACS equals 0 and add it to sum column TACS The query needs to be grouped by a separate column name TOE. TICS TACS 5 0 5 5 1 0 3 3 so the answer should be (5 + 1) + (5+ 3)=14 I stumble over arrays and formating queries to make certain types of arrays. I figure 2 queries would be silly. If anyone could point me in the right direction regarding this query I'd be much obliged. Thanks so much for taking the time to read my question!
  9. Yes! Thank you! I appreciate the fast, straightforward & non-judgemental response!
  10. Beginner here. Not sure why but I arrays are a huge source of frustration for me. I have this query: $query = $this->_db->getQuery ( true ); $query->select( 'a.table,a.places'); $query->from ( '#__tbb_reserves as a '); $query->where ( 'id = ' . $tid ); $this->_db->setQuery ( $query ); $myarray =$this->_db->loadRowList(); resulting in this array array { [0]=array { [0]= "9" [1]="10" } [1]= array { [0]= "5" [1]= "10" } [2]= array { [0]= "4" [1]= "6" } } From which I would like to create 2 new arrays: one from key [0] $array1 = array(9,5,4) and one from key [1] $array2 = array(10,10,6) Any help on how I would go about this is appreciated. Please let me know if I have left anything important out in my question. Also, if anyone knows of a good tutorial on the subject I would be very grateful.
×
×
  • 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.