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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:32:26+00:00 2026-05-25T13:32:26+00:00

I have a query: SELECT * FROM categorys LEFT JOIN category_info ON categorys.cat_id=category_info.cat_id WHERE

  • 0

I have a query:

SELECT * FROM categorys 
LEFT JOIN category_info ON categorys.cat_id=category_info.cat_id 
WHERE `cat_name` = 'aname'
ORDER BY `cat_order`

When I run this in phpMyAdmin I get an cat_id back regardless of if there is a match in the second table.

However, when I run this query in my PHP code I get a blank cat_id back, as shown by this print_r():

Array ( [cat_id] => [cat_name] => baths [type] => main [cat_order] =>
99 [cat_img] => [display] => 1 [deleted] => 0 [desc_id] => [desc] =>
[text] => )

Why would there be a different result when the query is exactly the same?

EDIT:
My PHP code:

$getcatidsql = "SELECT * FROM categorys 
LEFT JOIN category_info ON categorys.cat_id=category_info.cat_id 
WHERE `cat_name` = '{$cname}'
ORDER BY `cat_order";   
$getcatidresult = $db->query( $getcatidsql );
$catdata = $db->fetchRow( $getcatidresult );

function query() {
  $this->query_total++;
  if (func_num_args() == 1) {
    $sql = func_get_arg(0);
  } else {
    $args = func_get_args();
    for ($i=1;$i<count($args);$i++) if (!is_numeric($args[$i])) $args[$i] = '"'.mysql_real_escape_string($args[$i]).'"';
    $sql = vsprintf(array_shift($args),$args);
  }
  if ($result = mysql_query($sql,$this->db_connection)) {
    return $result;
  } else {
    $this->dberror( $this->db_connection, $sql );
  }
}

function fetchRow($result,$type=MYSQL_ASSOC)
{
    if($result)
        $row = mysql_fetch_array($result,$type);
    return $row;
}
  • 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-25T13:32:26+00:00Added an answer on May 25, 2026 at 1:32 pm

    I think you must not use select * (also because of same column names in both tables) , but select exactly fields for your needs

      select table_name.field, table_name.field2, other_table_name.field1 
    

    .. and you’ll get right results from both php code and phpmyadmin

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

Sidebar

Related Questions

I have this query SELECT products_list.id_cat_unique, products_categories_list.*, COUNT(products_list.id_cat_unique) as counter FROM products_categories_ids LEFT JOIN
I have this query: SELECT * FROM sample INNER JOIN test ON sample.sample_number =
I have query SELECT helpc.cid, COUNT(help.cid) AS children_count FROM air_help_category AS helpc LEFT JOIN
Consider: SELECT * FROM `product` left join category on product.category_id = category.id This query
So I have this query that works perfectly: SELECT users.*, GROUP_CONCAT(categories.category_name) AS categories FROM
I have this query: SELECT * From checkfinale where AssociateID = 51 AND `CompletedDate`
i have sql query select * from Roles Join Users On Roles.Role=Users.RoleId it return
Let's say I have this query: select * from table1 r where r.x =
Hi guys I am having issue I have this query: SELECT * FROM useraccount
i have this sql query select * from table where name like ? but

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.