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

The Archive Base Latest Questions

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

I have the following MYSQL select statement in a php file that was provided

  • 0

I have the following MYSQL select statement in a php file that was provided me by a programmer sometime ago.

I’m trying to make some edits to the file (I know enough PHP to “get myself into trouble”).

Unfortunately, I don’t understand this statement and what it means. I’ve never seen a select statement with “DOTS” in it (ie. a.weight or b.oil_type_id)

I don’t understand howto read it. Here’s the statement. Anyone know what this is supposed to mean?

$query11 = "SELECT avg(a.weight) as weight_avg
           from oil_type a, oil_data b
           where b.oil_type_id = a.oiltype_id
           and b.viscosity_id = ". $viscosity_id_this;
  • 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-25T02:12:57+00:00Added an answer on May 25, 2026 at 2:12 am

    You are qualifying the columns with their table names (or rather, their aliases):

    SELECT avg( a.weight ) as weight_avg 
      FROM oil_type a, oil_data b  -- b is an alias for oil_data, a is an alias for oil_type
                                   -- also, there's an implicit join here
     WHERE b.oil_type_id = a.oiltype_id 
       AND b.viscosity_id =". $viscosity_id_this;
    

    This is necessary to remove ambiguity (ie: when a column with the same name exists in both tables). If the column names are not the same, you could use this for clarity.

    The whole query could be rewritten as:

        SELECT AVG(a.weight) as weight_avg 
          FROM oil_type AS a
    INNER JOIN oil_data AS b 
            ON b.oil_type_id = a.oiltype_id 
         WHERE b.viscosity_id = $viscosity_id_this;
    

    Which might be more clear (or not).

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

Sidebar

Related Questions

This is for MySQL and PHP I have a table that contains the following
I have code with the following form: <?php function doSomething{ //Do stuff with MySQL
I'd like to write the following as a MySQL SELECT statement to cut down
I have the following jQuery statement: $.ajax({ type: POST, url: db.php, data: word=+ tmpWord,
I have the following script: <?php $mysqli = new mysqli('localhost', 'user', 'password', 'database'); $statement
Little question: With the following code... <?php $statement = SELECT * FROM TABLE; $query_unfetched
I have the following select statement: $res = mysql_query(select * from Table where Name='{$_REQUEST['name']}');
I'd really like some help with the following MySQL / PHP problem (maybe bug?)
I have the following in php: public function myfunction($v){ //ini_set(memory_limit,32M); $v=mysqli_real_escape_string($this->connection,$v); $stmt=mysqli_prepare($this->connection,SELECT * from
I have the following MySQL. SELECT `outputtable`.`date`, count(*) as `count` FROM ( SELECT CONCAT(DATE(`mytable`.`starttime`),'

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.