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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:06:00+00:00 2026-06-17T17:06:00+00:00

Basically, I have a function that exports data to a csv format for excel…

  • 0

Basically, I have a function that exports data to a csv format for excel… I’m trying to have a single query to select all of the sales record within the selected time period, but I need the first column that is queried to come from another table. The current query I have is as follows:

$select = "SELECT `record_date` AS 'Sale Date',
                  `record_order_number` AS 'Order #',
                  `record_activity_number` AS 'Activity #',
                  `record_total_diy_revenue` AS 'Revenue $'
             FROM st_entered_records 
            WHERE `record_user_id` = '$this->user_id' AND 
                  `record_date` BETWEEN '$this->start_date' AND '$this->end_date' ";

Before

`record_date` AS 'Sale Date'

I need it to run a second select to get the users first and last name in format:

"LastName, FirstName"
 (user_last_name)", "(user_first_name) from a second table (st_users) 
 where `user_id` = '$this->user_id'

Any help would be appreciated! 🙂

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

    You could do a join example of one:

        SELECT t2.lastName,t2.firstName,
               t1.record_date AS 'Sale Date',
               t1.record_order_number AS 'Order #',
               t1.record_activity_numbe AS 'Activity #',
               t1.record_total_diy_revenue AS 'Revenue $' 
    
        FROM st_entered_records1 t1
    
        INNER JOIN stusers t2 ON t1.record_user_id=t2.userid
    
        WHERE t1.userid = $this->user_id AND
        t1.record_date BETWEEN $this->start_date AND $this->end_date
    

    Be sure you match the table names and field names I’m sure you already know this 🙂

    EDIT: Stongly advise you do not use MYSQL_*

    Reason:

    This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.

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

Sidebar

Related Questions

I'm testing a C++ class with a number of functions that all have basically
I have a function which accepts fromRange and ToRange of an Excel cell. basically
I basically have a program that filters records from one excel file to another
I am trying the following. I have the function that displays a hidden list
Basically I have a function that reads cookies. getCookie('message'). When getCookie('message') value changes I
To start out with, I basically have a function that opens up a text
Basically I have a function that passes this... I need this function to be
I basically have a PHP function that is in a giant foreach statement and
I have an animated character swc that is an empty skeleton basically (has all
I'm getting an weird error using queues/multiprocessing. I basically have a function that takes

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.