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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:25:14+00:00 2026-05-12T08:25:14+00:00

I have a script which generates queries in the following fashion (based on user

  • 0

I have a script which generates queries in the following fashion (based on user input):

SELECT * FROM articles 
 WHERE (articles.skeywords_auto ilike '%pm2%') 
  AND spubid IN (
   SELECT people.spubid FROM people 
   WHERE (people.slast ilike 'chow') 
   GROUP BY people.spubid) 
 LIMIT 1;

The resulting data set:

Array ( [0] => 
  Array ( 
          [spubid] => A00603 
          [bactive] => t 
          [bbatch_import] => t 
          [bincomplete] => t 
          [scitation_vis] => I,X 
          [dentered] => 2009-07-24 17:07:27.241975 
          [sentered_by] => pubs_batchadd.php 
          [drev] => 2009-07-24 17:07:27.241975 
          [srev_by] => pubs_batchadd.php 
          [bpeer_reviewed] => t 
          [sarticle] => Errata: PM2.5 and PM10 concentrations from the Qalabotjha low-smoke fuels macro-scale experiment in South Africa (vol 69, pg 1, 2001) 
          [spublication] => Environmental Monitoring and Assessment 
          [ipublisher] => 
          [svolume] => 71 
          [sissue] => 
          [spage_start] => 207 
          [spage_end] => 210 
          [bon_cover] => f 
          [scover_location] => 
          [scover_vis] => I,X 
          [sabstract] => 
          [sabstract_vis] => I,X 
          [sarticle_url] => 
          [sdoi] => 
          [sfile_location] => 
          [sfile_name] => 
          [sfile_vis] => I
          [sscience_codes] => 
          [skeywords_manual] => 
          [skeywords_auto] => 1,5,69,2001,africa,assessment,concentrations,environmental,errata,experiment,fuels,low-smoke,macro-scale,monitoring,pg,pm10,pm2,qalabotjha,south,vol 
          [saward_number] => 
          [snotes] => 

)

The problem is that I also need all the columns from the ‘people’ table (as referenced in the sub select) to come back as part of the data set. I haven’t (obviously) done much with sub selects in the past so this approach is very new to me. How do I pull back all the matching rows/columns from the articles table AS WELL as the rows/column from the people table?

  • 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-05-12T08:25:14+00:00Added an answer on May 12, 2026 at 8:25 am

    Are you familiar with joins? Using ANSI syntax:

    SELECT DISTINCT *
      FROM ARTICLES t
      JOIN PEOPLE p ON p.spubid = t.spudid AND p.slast ILIKE 'chow'
     WHERE t.skeywords_auto ILIKE'%pm2%'
     LIMIT 1;
    

    The DISTINCT saves from having to define a GROUP BY for every column returned from both tables. I included it because you had the GROUP BY on your subquery; I don’t know if it was actually necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with following script. It generates a list of places which
I have a script which generates input boxes dynamically, var gridBuilder = function() {
Let's say I have a server side script which generates JSON from a simple
I have a script which generates an XML file when the user accesses the
I have a perl script which when run from the command line generates a
I have a php script (generator.php) which generates certain HTML/XML/SVG depending on various conditions.
I have a page which is largely created by DOM script, which generates a
I have a script which creates a user-defined object like this: obj = new
I have a bash script which generates an SCP command to execute. The relevant
I have a foreach syntax which generates following outcome: array 0 => array 'value'

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.