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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:48:41+00:00 2026-06-12T22:48:41+00:00

This is my query: SELECT DISTINCT ap.apptype_id FROM tblSubmission AS s JOIN tblApp AS

  • 0

This is my query:

SELECT DISTINCT ap.apptype_id
FROM tblSubmission AS s
JOIN tblApp AS ap ON ap.app_id = s.app_id
WHERE s.app_id =406
OR s.app_id =180
OR s.app_id =179

It returns just unique apptype_ids pertaining to rows in a database. It works right now like it should, except for the fact that it returns a multidimensional array, rather than a single-dimension array. I could go ahead and write a PHP function that resolves this, but I would rather have the query return the array properly rather than make the server do extra work to fix the problem with the query. Can anyone help me out?

Also, if anyone sees a way I can optimize this query to make it even quicker, that would be great as well!

function db_query($querystring) { 
   $rec_set = array(); 
   $result = mysql_query($querystring); 
   if (!$result) { 
       // do nothing, query might have failed but it might have just returned no results          
       #echo ("Invalid Query Result:<br /><b>" . $querystring . "</b><br />"); // debug 
    }elseif($result === true){ 
       // do nothing, query didn't return anything but succeeded 
    }else{ 
       while ($row = mysql_fetch_assoc($result)) { $rec_set[] = $row; }            
       mysql_free_result($result); 
    } 
    return $rec_set; 
  }
  • 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-12T22:48:42+00:00Added an answer on June 12, 2026 at 10:48 pm

    You’re returning two records so it’s multidimensional.

    You have DISTINCT ap.apptype_id and your query finds two records with distinct ids.

    EDIT: just to clarify; in a single dimensional array as you’d look for I believe the result you intended was:

    array([7], [2]) // i.e your two distinct ids.
    

    Try to remember that with mysql you get returned the column header too so this layout wouldn’t make sense.

    EDIT 2:

    Maybe something like this would help?

    $a = array(
        0 => array('first'=>7),
        1 => array('second'=>2)
    );
    
    $row = array_map('implode', $a);
    

    OUTPUT:

    array(2) { [0]=> string(1) "7" [1]=> string(1) "2" }
    

    The array_map is the function you’d want here. It should work as you need.

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

Sidebar

Related Questions

I am using this query: SELECT DISTINCT pat.PublicationID FROM dbo.PubAdvTransData AS pat INNER JOIN
I have this query: SELECT DISTINCT IM.EDIFICIOS_ID, TI.TITULAR FROM IMPORTACION IM INNER JOIN I_EDIFICIO
This is my current query: SELECT DISTINCT t.* FROM filter AS f INNER JOIN
So I have this query: SELECT DISTINCT(b.friend_id) AS possible_id FROM friend_friends a JOIN friends_friends
I have this query: SELECT DISTINCT(b.friend_id) AS possible_id FROM friends_friends a JOIN friends_friends b
I have this query... SELECT Distinct([TargetAttributeID]) FROM (SELECT distinct att1.intAttributeID as [TargetAttributeID] FROM AST_tblAttributes
I have a mysql query like this: $topicreplycount = mysql_query('SELECT COUNT(DISTINCT post_msg_id) FROM phpbb_attachments
I've used this MySQL query to get data: SELECT DISTINCT A.*, B.username FROM posts
This is my base query select distinct a.projects , case when(billing_fy!=0) then(select round(((sum(cost_project)/(sum(billing_fy)/((10/12)*365)))),2) from
I have this query: SELECT DISTINCT phone, department FROM `users` WHERE ((SUBSTRING(phone,1,3) = '399')

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.