Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8890333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:28:38+00:00 2026-06-14T22:28:38+00:00

I have a database with this kind of a table, has more than 10

  • 0

I have a database with this kind of a table, has more than 10 million rows.

ID  colA    colB    Length
1   seq1    seq11   1   
2   seq1    seq11   11  
3   seq3    seq33   21  
4   seq3    seq33   14  

I want to loop though colA first, get the relevant colB value, and check if there are any other occurrences of the same value.
For example in colB (seq11) there are 2 occurrences of colA(seq1), this time I have to combine those and output the sum of the length. Similar to this:

ID  colA  colB   Length
1   seq1  seq11  12
2   seq3  seq33  35

I am a bit Java guy, but because my colleague has written everything in PHP and this will be just an adding, I need a PHP solution.
With Java I would have used hashmap, so that I would have the colA data once and just increment the value of “Length Column”.


I tried this query in order to group by occurences:

SELECT COUNT(*) SeqName FROM SeqTable GROUP BY SeqName HAVING COUNT(*)>0;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:28:39+00:00Added an answer on June 14, 2026 at 10:28 pm

    In PHP you can use an array like an hash map

    $array = Array();
    $array['seq1'] = Array();
    $array['seq1']['seq11'] = 0;
    $array['seq1']['seq11']++;
    

    Or you can use an SQL query like this one:

    select id,colA,colB,sum(Length) as Length from {tableName} group by colA,colB order by colA, colB;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this database structure, SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; CREATE TABLE IF NOT EXISTS `announces` (
i have database table like this +-------+--------------+----------+ | id | ip | date |
I have a database on a SQL Server 2000 server. This database has a
Basically I have a database contain some kind of logs, each record has an
I have a Database with this fields: Firstname, Lastname, picture. I have a gtk.Label
I have mysql database like this id | code 1 | bok-1 2 |
Suppose I have a database like this: This is set up to give role-wise
In SQL Server, I have a database abc . In this database I have
I have created my database by this sql query: (CREATE DATABASE + DBName +
I have a db2 database with this charset options: db2 get db cfg for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.