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 8665993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:37:16+00:00 2026-06-12T17:37:16+00:00

In the example below I have a bibliographic table with authors and their papers.

  • 0

In the example below I have a bibliographic table with authors and their papers. For example, authors ‘001’ and ‘003’ wrote article ‘678’ together.

articleId | authorId
123 | 001
123 | 002
345 | 002
345 | 003
345 | 004
678 | 001
678 | 003

I need to select co-occurrences between authors based on their common authorship. For example, for table above I need to construct the following table:

AuthorA | AuthorB
001 | 002
002 | 003
002 | 004
003 | 004
001 | 003

First table is very large (approx. 1.800.000 rows). When I first try with MS SQL Server 2008, construction of the second table was fast, but I’m stuck with MySQL now. I use the following query:

SELECT foo.authorId AS authorA, bar.authorId AS authorB
  FROM
    (SELECT * FROM tblAuthorHasBib) AS foo,
    (SELECT * FROM tblAuthorHasBib) AS bar
  WHERE
    foo.articleId = bar.articleId
  AND
    foo.authorId <> bar.authorId
  GROUP BY foo.authorId, bar.authorId

How to rewrite my query to be as fast as with MS SQL? Thanks in advance for any pointer.

  • 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-12T17:37:17+00:00Added an answer on June 12, 2026 at 5:37 pm

    You could write your query as shown below, which will avoid any using the GROUP BY clause and any in-line views.

    SELECT foo.authorId AS authorA, bar.authorId AS authorB
    FROM tblAuthorHasBib foo
    JOIN tblAuthorHasBib bar
       ON foo.articleId = bar.articleId 
    WHERE foo.authorId != bar.authorId
    

    Alternatively, as per @1osmi’s comment, if you wanted only unique permutations of authors then you could replace the != with < as shown below

    SELECT foo.authorId AS authorA, bar.authorId AS authorB
    FROM tblAuthorHasBib foo
    JOIN tblAuthorHasBib bar
       ON foo.articleId = bar.articleId 
    WHERE foo.authorId < bar.authorId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a table t_points in mySql like example in below. Name Surname Point
I have a table as example below: Prices ID* low *high**value 1* 1 *4**29.0
I have three tables kinda like the example below: TABLE CARS carId carName -----
In the simplified example below I have a DataContext and Repository which I think
I have posted an example below and the desired result . I saw a
Reproducible example below. I have a simulation loop, within which I occasionally have rows
I have a page (contrived example below) with a Google doc and a download
In the example below, I have a model Proof which contains a foreign key
Tech used: PHP 5.3.10 Hi, I have an array (example below) I need to
Let's have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;

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.